Twill is an open source CMS toolkit for Laravel that helps developers rapidly create a custom admin console that is intuitive, powerful and flexible. Chat with us on Discord at https://discord.gg/cnWk7EFv8R.
A quick PR to improve saveRelated to work with models, I wanted to use it and according to the phpdoc it accepts an array of Twill model, but this is not the case (it only accepts an array with id and endpointType)
This PR allows the method to accept models as well and improves the performance by using only one where instead of 3 which would iterate 3 times over the collection
I also added $item->unsetRelation('related') in loadRelated, otherwise there is a circular reference in the model relation (model -> pivot -> related -> model ...) which causes an infinite loop when using model->toArray()
A quick PR to improve
saveRelated
to work with models, I wanted to use it and according to the phpdoc it accepts an array of Twill model, but this is not the case (it only accepts an array withid
andendpointType
)This PR allows the method to accept models as well and improves the performance by using only one
where
instead of 3 which would iterate 3 times over the collectionI also added
$item->unsetRelation('related')
in loadRelated, otherwise there is a circular reference in the model relation (model -> pivot -> related -> model ...) which causes an infinite loop when usingmodel->toArray()