$data = ['name' => 'John Doe', 'email' => 'johndoe@example.com', 'address' => 'New York']; $user = new User; $user->fill($data); $user->save();
$user = User::find(1); $userData = ['name' => $user->name, 'email' => $user->email, 'address' => $user->address]; $user->fill($userData); $user->save();These examples show how the fill method is used to fill the model's attributes with data either from an array or from the database. With this method, we can quickly and easily update model attributes without having to set each attribute individually.