Skip to content

Commit

Permalink
T4 Update UserController.php
Browse files Browse the repository at this point in the history
  • Loading branch information
imtyaz-17 authored Jul 4, 2024
1 parent 9351425 commit 16819c5
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions app/Http/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,13 @@ public function check_create($name, $email)
{
// TASK: find a user by $name and $email
// if not found, create a user with $name, $email and random password
$user = NULL;
$user = User::where('name', $name)->where('email', $email)->first(); // updated or created user
if (!$user) {
$user = User::create([
'name' => $name,
'email' => $email,
'password' => bcrypt(str_random(8))
]);

return view('users.show', compact('user'));
}
Expand All @@ -43,13 +49,7 @@ public function check_update($name, $email)
{
// TASK: find a user by $name and update it with $email
// if not found, create a user with $name, $email and random password
$user = User::where('name', $name)->where('email', $email)->first(); // updated or created user
if (!$user) {
$user = User::create([
'name' => $name,
'email' => $email,
'password' => bcrypt(str_random(8))
]);

}
return view('users.show', compact('user'));
}
Expand Down

0 comments on commit 16819c5

Please sign in to comment.