1
I have a script in Arabic that in eloquent need to put a condition in eloquent instead of selecting all as is,need to select according to the user id.
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);
						
I suggest you take a look at the documentation of the eloquent/Aravel https://laravel.com/docs/master/eloquent. In advance, the find function has as an integer that would be the id (Event::find(1)) defined in its table or an array of integers (Event::find([1, 2, 3])).
– sant0will
Pass an id(integer) instead of the string... if the id you want to search for is 1 it would be Event::find(1);
– JrD
My wish would be a variable, which would contain the user id that is currently logged in.
– Noscin
@Noscin Improve your question, what do you really want to do? Which variable will be used? The code is complete?
– sant0will
Thanks for trying to help me in the query I managed to resolve by putting $data = Event::Where('userid', $user)->get();
– Noscin