Good evening, I'm trying to make a log-in page that displays a redirection button when there are not registers in the users database. When there are one or more registers in the database, display all the users to select one of them. The problem is that the view doesn't change when the database has a register.
Here you have the blade template code:
@if(empty($users))
<div class="grid-item" id="grid-item5">
<div id="title">
<h1>Welcome</h1>
<p>We see there aren't users</p>
</div>
<div id="loginForm">
<button type="button" onclick="window.location=''">Create user</button>
</div>
</div>
@else
<div class="grid-item" id="grid-item5">
<div id="title">
<h1>Select an user</h1>
</div>
<div id="loginForm"></div>
</div>
@endif
Here you have the controller code:
public function index()
{
$users = User::all();
return view('users.index')->with('users', $users);
}
Here you have the web.php routing:
Route::get('/', function () {
return view('landing');
});
Route::get('/newUser', function () {
return view('createUser');
});
Route::resource('users', UserController::class);
Can anyone help me? I don't know to solve this...
Aucun commentaire:
Enregistrer un commentaire