lundi 17 octobre 2016

Using protected $relations in User model?

I have two tables: Users, Workers.

The relationship is: Users.id = Workers.user_id

In User model I set related model as:

protected $relations = ['workers'];

And there is method workers in User model:

public function workers()
    {
        return $this->hasOne('App\Workers', "user_id");
    }

So, in conclusion when I catch the object:

dd(Auth::user());

I dont have here attributes from related model workers



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire