I get a collection from my database with
$events = DB::table('events')
->select('id', 'eventId', 'resourceId', 'title', 'start', 'end')
->get();
and want to add a field color so that I can set the color value depending on the value of the field title. My approach does not work, the echo and put gives an error.
$events->put('color', 'blue');
$events->each(function($item, $key){
if($item == 'Garage')
echo $item;
});
colorto thevisiblearray and define agetColorAttributefunction on the model: laravel.com/docs/7.x/eloquent-mutators#defining-an-accessor What words 5 do you see?colorto the collection which does not exist in the database.