Reputation: 4979
I have following tables.
id
name
id
name
id
name
id
event_id
card_id
An user has many events and cards. An user can accepts cards from other user which he met at an event.A row will be added under transfers table whenever a card is accepted by a user, this row links a card_id
with event_id
. I am looking for a way to check a card (card_id
) is added under the transfers table for a logged in user's event(event_id
).
eg:-
auth()->user()->events->transfers->where(([['card_id', '=',$cardid]])->find());
Can someone help me by telling what is the best way to handle above situation using eloquent?
Upvotes: 0
Views: 53
Reputation: 1300
Add a belongsToMany
-relation
Take a look at the official documentation: https://laravel.com/docs/5.1/eloquent-relationships
Upvotes: 1