I am new to Laravel. I am now able to register users, log them in. But after login, I don’t want to display register and login pages. I want to display logout link. This is easy for me with core php.
I want something similar like the one below.
<?php
if(isset($_SESSION['id'])){
?>
<a href="index.php">Home</a>
<a href="dashboard.php">Dashboard</a>
<a href="logout.php">Logout</a>
<?php
}else{
?>
<a href="index.php">Home</a>
<a href="register.php">Register</a>
<a href="login">Login</a>
<?php
}
?>
3
Answers
Blade has @auth, which checks if user is logged in or not
Also has @guest (ending with @endguest) which does the opposite.
And if you named your routes, you can for example:
This way the url changes if you change your routes.
This is How I did it. It’s working though, but I don’t know if it’s the right way.
‘users’ is the user id as the Session variable from database