vendredi 27 janvier 2017

hasOne relationship and associate()?

I have this relationship :

  public function company(){
        return $this->hasOne('App\Models\User','personal_users_business_users', 'user_id', 'business_user_id');
    }

When i try this:

  $user->company()->associate($business_user_id);

Im getting this error:

Call to undefined method Illuminate\Database\Query\Builder::associate()

I have pivot table personal_users_business_users and it has user_id, business_user_id, approved

And now i want to insert in that pivot table business_user_id. What im doing wrong?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire