jeudi 21 novembre 2019

How to organize the loading of all relations in the polymorphic connection Laravel 5.1?

There is a main model (Pattern) having many models (Layer ). There is a model (Slayer) that has a polymorphic relationship to the models (Image and Text). The model (Text) has no child relationships, whereas (Image) has a one-to-one relationship to the model (File)

In what way, when unloading the model (Pattern), pull up all (Layer's) each with its own additional relations?

Pattern::whereId($id)->with('layers.layereable')->get();

image



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire