vendredi 21 juillet 2017

Retrieving relevant record from a relationship

I am allowing user to search by type which is passed into a function:

public function typeSearch($type)
{
    $events = Event::where('type', $type)
        ->with('entities')
        ->get();
    return view('events.searchResultEvents', compact('events'));
}

Which works nearly as it's supposed to do, it does retrieve the entities but not the right entities for example:

Event id = 25, entity_id = 2 it retrieves: Entities id = 25 while it should be 2.

How can I change this so it retrieves the right record?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2vHV6fj
via IFTTT

Aucun commentaire:

Enregistrer un commentaire