我做了一个项目,laravel 5.3 AAAND 我想要的图表与https://erik.cat/projects/Charts/docs/4#installation,我希望它是动态的,标签字段为用户参与与它的任务项目的冠军数组(希望我是清楚的)方法照亮查看查看:: __的toString() - 类stdClass的的对象无法转换为字符串
,直到如今我有这样的事情
$idUser = Auth::user()->id;
$tasksUsed = DB::table('user_task')
->join('tasks', 'tasks.id', '=', 'user_task.task_id')
->join('projects', 'projects.id', '=', 'tasks.project_id')
->select('projects.title')->where('user_task.user_id',$idUser)->get();
// dd($tasksUsed->toArray());
$chart = Charts::create('donut', 'morris')
// ->view('custom.line.chart.view') // Use this if you want to use your own template
->title('My nice chart')
->labels($tasksUsed->toArray())
->values([3,4])
->dimensions(300,300)
->responsive(false);
,这让我这个错误,我不知道如何解决它
Method Illuminate\View\View::__toString() must not throw an exception, caught ErrorException: Object of class stdClass could not be converted to string
...\vendor\consoletvs\charts\resources\views\morris\donut.blade.php)
在我认为我这样做:{! $ chart-> render()!!} –
非常接近。检查该库的文档,因为'$ chart-> render()'返回一个对象。 – manix