laravel difference between fill and update

Solutions on MaxInterview for laravel difference between fill and update by the best coders in the world

showing results for - "laravel difference between fill and update"
22 Jan 2020
1<?php$user = User::find(1); 
2// This will update immediately
3$user->update(['first_name' => 'Braj', 'last_name' => 'Mohan']);
5// This will not update underlying data store immediately
6$user->fill(['first_name' => 'Fred', 'last_name' => 'Avad']);
7// At this point user object is still only in memory with updated values but actual update query is not performed.
8// so we can have more logic here 
9$user->is_active = true;
10// Then finally we can save it.
11$user->save(); // This will also make user active