Complete all stats

This commit is contained in:
Thuan Bui
2025-04-04 11:57:49 +09:00
parent fcea780b69
commit c7bf3ea95d
6 changed files with 72 additions and 4 deletions
+8 -2
View File
@@ -45,7 +45,13 @@ class UserController extends Controller
{
// TASK: find a user by $name and update it with $email
// if not found, create a user with $name, $email and random password
$user = NULL; // updated or created user
$user = User::updateOrCreate(
['name' => $name],
[
'email' => $email,
'password' => Hash::make(Str::random(12)),
]
);
return view('users.show', compact('user'));
}
@@ -57,7 +63,7 @@ class UserController extends Controller
// $request->users is an array of IDs, ex. [1, 2, 3]
// Insert Eloquent statement here
$users = User::whereIn('id', $request->users)->delete();
return redirect('/')->with('success', 'Users deleted');
}