📜  laravel 填充和更新的区别 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:53:56.990000             🧑  作者: Mango

代码示例1
update(['first_name' => 'Braj', 'last_name' => 'Mohan']);

// This will not update underlying data store immediately
$user->fill(['first_name' => 'Fred', 'last_name' => 'Avad']);
// At this point user object is still only in memory with updated values but actual update query is not performed.
// so we can have more logic here 
$user->is_active = true;
// Then finally we can save it.
$user->save(); // This will also make user active