Currently i am having to manually access the relationship of each event.
see below:
$events = Events::where('status', '!=', 'passed')->orderBy('created_at', 'desc')->take(20)->get();
foreach ($events as $event) {
$responses = Events::findOrFail($event->id)->responses()->where('user_id', '=', '1')->first();//TODO user_id hardcoded
if($responses) echo "The event has a response that belongs to the user";
else echo "The event doesnt have a response for that user";
}
Is there a way to chain the "Events::" Eloquent ORM completley?
Let me know if you need to see the the models although it's pretty standard.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire