如何在ConsoleTV /图表中获取类别的日期?

时间:2019-08-25 07:08:53

标签: laravel

错误:

Method Illuminate\Database\Eloquent\Collection::provinces does not exist.

代码:

  $data = App\Protection::with('provinces');
    $protection = Charts::create('bar', 'chartjs')
        ->title('title')
        ->elementLabel('total')
        ->dimensions(0, 300)
        ->labels($data->provinces()
        ->pluck('title')
        ->implode(' '))
        ->values($data->pluck('benefit_kind'))
        ->responsive(false);

保护模型:

class Protection extends Model
{
protected $guarded = [];
public function user()
{
    return $this->belongsTo(User::class);
}
public function provinces()
{
    return $this->belongsToMany(Province::class);
}
public function districts()
{
    return $this->belongsToMany(District::class);
}

}

0 个答案:

没有答案