Chartjs-Query result into array in Laravel 6

0👍

You can use the pluck method to achieve what you want.

For instance:

$models = App\Model::all()

$models->pluck('year')->toArray(); // [2018, 2019, 2020]
$models->pluck('column1')->toArray(); // [11, 24, 15]
$models->pluck('column2')->toArray(); // [7, 12, 13]

You can read more about pluck here: https://laravel.com/docs/6.x/collections#method-pluck

Leave a comment