polymorphic relation backwards query laravel 4
I've been searching the web for the answer and haven't found any, so
here's the problem:
I have 3 table:
Events Tournaments Leagues
Event table: id eventable_id eventable_type (League or Tournament)
Tournaments table: id name
Leagues table: id name
What I want to do is get the event that has the name = Event name.
I tried:
$event = Events::get()->eventable->where('name', '=', $event_name)->first();
Without any success. I tried:
$event = Events::eventable()->where('name', '=', $event_name)->first();
No success and I have tried a lot of different ways and I just can't
figure it out....
Thanks, Ara
No comments:
Post a Comment