Support the ongoing development of Laravel.io →
Database Eloquent
Last updated 2 years ago.
0

Would not be easier to do something like:

$user = User::find(2);

if ($user->organization)
    return 'YES';
else
    return 'NO';
Last updated 2 years ago.
0

you can send relationships code?

Last updated 2 years ago.
0

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();
    }
}
Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Bolandish bolandish Joined 2 Jun 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.