php - Laravel Eloquent - belongs to many through -


i have sites, pages, elements , element_creators tables, :

   sites      id      ...    pages      id      site_id      ...    elements      id      page_id      ...    element_creators      id      element_id      ... 

i'm able retrieve element creators linked page

    $this->belongstomany('elementcreator', 'elements', 'page_id', 'element_creator_id'); 

is there simple way retrieve element creators specific site (through pages) ?

thank !

you may try this:

$site = site::with('pages.elementcreators')->find(1); // 1 id example 

then may access elementcreators using this:

$elementcreators = $site->pages->fetch('elementcreators'); 

Comments

Popular posts from this blog

php - render data via PDO::FETCH_FUNC vs loop -

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

The canvas has been tainted by cross-origin data in chrome only -