I have a script in laravel which in eloquent I need to put a condition in eloquent instead of selecting all as it is, I need to select it according to the id of the user.
I checked that I should use Event :: find instead of Event: all (), but it is returning error.
$events = [];
$data = Event::all();
if($data->count()) {
foreach ($data as $key => $value) {
$events[] = Calendar::event(
$value->title,
true,
new \DateTime($value->start_date),
new \DateTime($value->end_date.' +1 day'),
null,
// Add color and link on event
[
'color' => '#ff0000',
'url' => '#',
]
);
}
}
$calendar = Calendar::addEvents($events);