Answers for "laravel difference between fill and update"

PHP
0

laravel difference between fill and update

<?php$user = User::find(1); 
// This will update immediately
$user->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
Posted by: Guest on April-28-2020

Code answers related to "laravel difference between fill and update"

Browse Popular Code Answers by Language