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.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire