dimanche 24 septembre 2017

hasManyThrough with an intermediate pivot table

Description:

My application is structured as follows: Property has a Many-Many relationship with Manager, and a Unit has a One-Many relationship with a Property, i.e. A manager can manage multiple properties, one property can have multiple manager accounts and one property can have multiple units.

I would like to have a HasManyThrough relationship on the manager to get all his units, so ideally it would look something like: $managers->units instead of having through loop through each property and call $property->units on it. Is this possible with the current version of laravel?

Tables:

managers:

  • id

properties:

  • id

managers_properties:

  • manager_id
  • property_id

units:

  • id
  • property_id


from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2fjZv1I
via IFTTT

Aucun commentaire:

Enregistrer un commentaire