Answers for "model refresh laravel"

PHP
0

Laravel model refresh queries

$flight = Flight::where('number', 'FR 900')->first();

$freshFlight = $flight->fresh();
Posted by: Guest on July-20-2021
1

model refresh laravel

$user =new App\Models\User()
  $user->name = "ali"
  $user->email = "[email protected]"
  $user->password = bcrypt("123")
  $user->save()
  
  $user->name  = "mohamad"
  $user->refresh()
  
  
  echo $user 
  //output is 
{  id: 1,
     name: "ali",
     email: "[email protected]",
     email_verified_at: null,
     password: "$2y$10$MmcGpLe7bN1FhOqpKZKXr.cxndIhWbn.Libs7JpCNDwhDyb5e5mqe",
     remember_token: null,
     created_at: "2021-07-14 08:06:59",
     updated_at: "2021-07-14 08:06:59",
}
Posted by: Guest on July-14-2021

Browse Popular Code Answers by Language