Reputation: 1639
I'm using Laravel 5.1 and I have this code:
$settings = new Setting;
$settings = $user->settings()->first();
$settings->user_id = $id;
$settings->save();
and this code update user
model and does not save new. How I can save NEW not update?
Upvotes: 1
Views: 72
Reputation: 2800
You need to change the name of the variable in which you're fetching the settings like this
$settings_old = $user->settings()->first();
$settings = $settings_old->replicate();
$settings->user_id = $id;
$settings->save();
Upvotes: 1