Get 2024 Templates Mega Bundle!$1000 worth of 19 Bootstrap HTML, Vue & React Templates + 3 Vector Sets for just $99
Get for 99$

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?


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (10)


Looking for reliable garage door repair in FixnGotx? Our expert technicians provide fast, professional service for all your garage door needs. Whether it's a broken spring, off-track door, malfunctioning opener, or routine maintenance, we’ve got you covered. We pride ourselves on delivering top-quality repairs at competitive prices, ensuring your garage door operates smoothly and securely. With years of experience, we guarantee quick response times and lasting solutions. Trust fixngotx company Garage Door Repair for all your residential and commercial garage door services. Call us today for a free estimate and let us keep your garage door in perfect condition!



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>
. Where I can learn about these uses.



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
<a href="%7B%7B%20route("login")%20%7D%7D" target="_blank" rel="noopener noreferrer">Login</a>
@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?



I just checked and found, I am using the Laravel App.



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"


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(