Laravel: update vs fill

Let’s take a look at the difference between update and fill of Eloquent methods.

When using update, it does persist the changes immediately in the database, for example:

$user = User::find(1); 
// This will update the record immediately
$user->update(['first_name' => 'Imran', 'last_name' => 'Khan']);

On the other hand, let’s say if we don’t want to update record immediately, but set user to active before saving then fill() would be the handy option.

$user = User::find(1); 
$user->fill(['first_name' => 'Imran', 'last_name' => 'Khan']); 

$user->is_active = true; 
Author: Danyal
I'm working as programmer since 2002. Born, grew up, studied and worked in Pakistan now Im located in Denmark since 2006.