N
N
naneri2015-04-30 14:47:35
Laravel
naneri, 2015-04-30 14:47:35

Determine value from linked table with Eloquent?

I have the Users and Members tables, the Members table stores the team IDs for which the user applied. In theory, only one application has an Approved entry equal to 1.
If I have a user object in the template - how to find out if it has an Approved application in the members table?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vyacheslav Plisko, 2015-05-01
@AmdY

$user = User::find();
$user->members()->where('approved', 1)->get();
if ($user->members) ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question