Stop redirecting to Login Page and Show Home Page
I am using Metronic 8.1.7 Laravel and when I try to visit root (/) it automatically redirect to login page. I want to show a landing page and open login page when user click login button. How can I do this?
Replies (14)
A homeowner in Voorhees Township might notice cracks near windows, sticking doors, or changes in the basement walls and become concerned about the foundation. Researching foundation repair in voorhees township from nj can be a useful first step toward arranging an inspection and understanding the severity of the problem. Identifying the cause early can help prevent minor warning signs from developing into more extensive structural concerns.
Even a small leak beneath a bathroom sink can cause damage if it goes unnoticed for too long. Water can seep into cabinets and flooring, making a simple repair more complicated than it needed to be. Checking for damp spots, unusual water bills, and dripping connections is a good habit for any homeowner. Getting leaks repaired promptly can help prevent unnecessary damage and wasted water sewer camera inspection belleville il .
A small leak under the kitchen sink might not seem like much at first, especially if you can catch the water with a towel. But leaving it alone for too long can damage the cabinet and create an even bigger repair job. I've always felt it's better to deal with these things early rather than wait until the damage becomes obvious. Regular plumbing checks and timely repairs can help homeowners avoid unnecessary expenses and keep everything working properly plumber kiantone ny .
A dripping faucet might not look like a serious problem, but hearing that constant sound every night can get annoying pretty quickly. More importantly, even minor leaks can waste water over time. Checking worn-out washers, loose connections, and other common causes can help prevent unnecessary waste. Regular attention to household plumbing is one of those simple things that can make home maintenance much less stressful water .
Knowing where the water shutoff valves are is one of those simple things that can be extremely useful during a plumbing problem. Shutting off the supply quickly can help limit potential damage [LovFlow Plumbing Co]https://lovelandplumberco.com/ https://lovelandplumberco.com/
Hi Mamta,
To help clarify, you can refer to the usage of the < x-base-layout> component. The < x-error-layout> component is typically used for displaying 400 or 500 error pages, as shown in the examples. On the other hand, the < x-auth-layout> component is specifically used for authentication pages like login, registration, and forgot password pages.
In your case, you may want to use the < x-base-layout> component for your pages. You can find an example of how to use this component in your code. The < x-base-layout> component is defined in the app/View/Components/BaseLayout.php file using a Component.
I hope this helps clarify things for you. Let me know if you have any further questions or concerns.
Thanks
Hi Mamta,
To add a custom index page based on the auth layout, you can create a new blade file in the "resources/views/pages" directory, for example, "my-home-page.blade.php". Then, wrap your content with the < x-auth-layout> component like this:
<x-auth-layout>
// Your content here
</x-auth-layout> After that, open the "config/global/pages.php" file and update the view for the index page by changing it to "my-home-page", relative to the "resources/views/pages/" directory:
array(
"" => array(
"title" => "Dashboard",
"description" => "",
"view" => "my-home-page",
// ...
),
// ...
) This will make your custom page the new index page for your application.
Thanks
Hi,
Thank you for your reply. I know Metronic 8.1.7 Laravel does not support the CRUD, can you tell me what is the best practice of adding a new page to Laravel? I am using demo1. I want to keep my files separate so that update will not override my files. Is there any documentation for this. There are a lot of files. I found at some we use
<x-base-layout> at some place
<x-error-layout> <x-auth-layout> Hi Mamta,
Regarding your question, if you want to make the dashboard accessible without login, you would need to remove the user profile component that displays the avatar at the top bar. You can do this by modifying the code and removing the component from the template. After that, you could consider adding a login button in its place, which would allow users to log in and access the dashboard.
To address the error you mentioned, you need to modify the code in the views/layout/demo1/partials/header/_navbar.blade.php file. The error seems to be coming from the following line of code:
<img src="{{ auth()->user()->avatarUrl }}" alt="user" /> This line is trying to access the avatarUrl property of the auth()->user() object, which requires the user to be logged in.
If you want to allow guest users to view the dashboard, you will need to remove this line of code or replace it with a guest avatar image.
You can use
auth()->check() function to conditionally display the user avatar in the header based on whether the user is authenticated or not. Here's an example:@if(auth()->check())
<img src="{{ auth()->user()->avatarUrl }}" alt="user" />
@else
Login
@endif This code will display the user avatar if the user is logged in, and a login button if the user is not logged in.
I hope this helps! Let me know if you have any further questions.
Best regards.
Thank you for the code. Is it possible to show different view based on auth i.e., if user is logged in or not. May be it is possible to handle this from Middleware.
Hi Mamta,
Could you please let me know which Laravel framework you are using? Are you using the Laravel app or the Laravel starter kit? This information will help me provide you with the appropriate solution.
Thanks!
I download the main folder and used the Laravel folder. What is the difference between these 2. Is there any document for this?
If I remove
$route->middleware('auth');
from web.php I get
Attempt to read property "avatarUrl" on null
img src="php echo e(auth()->user()->avatarUrl); " alt="user"