lundi 29 juillet 2019

Elegant way to pass objects to Laravel's create method

Is there a more elegant way to do the following in Lavarel 5?

MyModel::create([
    'my_other_model_id' => $my_other_model->id,
    'my_other_other_model_id' => $my_other_other_model->id,
]);

I'd like to pass $my_other_model and $my_other_other_model in directly without all that tedious mucking about with ids.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/315y9T3
via IFTTT

Aucun commentaire:

Enregistrer un commentaire