Level 13
I'd go with https://laravel.com/docs/5.6/eloquent-resources
Where is the best place for formating model output? I have model called Event. Then I need to format results from the method all() of that model for using with fullCalendar js plugin.
There is an example of method for formating output:
foreach ($events as $key => $event) {
$data[$key] = [
'allDay' => true,
'color' => $event->course->color,
'end' => Carbon::createFromFormat("Y-m-d", $event->end)->addDay()->toDateString(),
'start' => $event->start,
'title' => $event->course->name . ' – ' . $event->trainers->pluck('name')->implode(', '),
'trainer_id' => $event->trainers()->pluck('trainers.id')->toJson(),
];
}
Where should be this method placed? Model, Controller, Helper. Or how to do itl
I possible to do somethink like this:
Event::all()->toFullCalendar();
Thank you in advance for your suggestions
I'd go with https://laravel.com/docs/5.6/eloquent-resources
Please or to participate in this conversation.