company table: id | name
user table id | name
company_user pivot table company_id | user_id
user model
public function companies() { return $this->belongsToMany(Company::class); }
company model
public function users() { return $this->belongsToMany(User::class); }
public function stores() { return $this->hasMany(Store::class); }
now, i want to access all the stores which belongs to companies where user has access to (via pivot).
//required function
public function accessibleStores() { // return $this-> }
is there any eloquent way to access the third model?
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2ogIF6x
via IFTTT
Aucun commentaire:
Enregistrer un commentaire