R
R
Romi2021-10-25 14:43:34
Laravel
Romi, 2021-10-25 14:43:34

Is there a convenient way to update relational models in Laravel?

Like how do we update one model:

$someModel->update($request->all());

not just one, but, say, two, which are in a one-to-one relationship, or some other?

I looked at the docks - I did not find anything on this topic.

Those. Let's say I want to update some data in a User and in a WishList which belongsTo User with a single PATCH request - is there a shorthand way to do this in Eloquent?

Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
pLavrenov, 2021-10-25
@pLavrenov

Looked at the documentation badly.
$someModel->relation()->update();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question