Would not be easier to do something like:
$user = User::find(2);
if ($user->organization)
return 'YES';
else
return 'NO';
IsraelOrtuno Thats not the solution. Your code tells me about the User has a organization.
class Organization extends Eloquent {
public function users()
{
return $this->belongsToMany('User', 'organizations_users')->withPivot('role_id')->withTimestamps();
}
}
class User extends Eloquent implements UserInterface, RemindableInterface
{
.......
public function organizations()
{
return $this->belongsToMany('Organization', 'organizations_users')->withPivot('role_id')->withTimestamps();
}
}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community