How can I update an existing Eloquent relationship in Laravel 4?

后端 未结 4 698
情深已故
情深已故 2021-02-07 13:08

I am trying to update the relationship of a one-to-many relationship in Laravel. Unfortunately I couldn\'t find any documentation for it. Can anyone help me?

This is wha

4条回答
  •  一向
    一向 (楼主)
    2021-02-07 13:49

    Hey you can refer the laravel docs for the solution.

    Link http://laravel.com/docs/4.2/eloquent#inserting-related-models

    $account = Account::find(10);
    
    $user->account()->associate($account);
    
    $user->save();
    

提交回复
热议问题