Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

eggplantSword's avatar

Have the same page on public and admin

I have an online store I'm building but I've run into an issue how do I deal with having the store both on a landing public page and also have it for the admin with the same links and everything?

My problem is the landing page is almost identical but it's not in the header, the landing header has the ability to login the user while the logged in header logs the user out. However besides the header / menu everything else is the same. The way I have my projects set up is using vue, so I have a layout component with the header / menu and use that in my pages to not repeat my code and just code what's on the specific page.

This store has 2 routes for now

Route::get('store', 'Auth\LoginController@showLoginForm')->name('login');

Route::group(['middleware' => 'auth'], function () {
    Route::prefix('admin')->group(function () {
        Route::get('/store', 'StoreController@index');
    });
});

The routes are different because I can't really use the same one because of the different headers, and also there would be clickable stuff to open product show pages and also sorting by categories which would redirect me to another route, how would I handle those routes then?

Should I create a store component and just add it to both places? How should I handle this?

0 likes
3 replies
husseinrubaie98's avatar

Well, there are two solutions for your problem:

  1. Create 2 headers for your website: Admin Header and Guest Header. In the landing blade page (landing.blade.php or whatever), you can check if the user is authenticated or not (Auth::check( ) returns true if the user is authenticated, false if guest) and the extend the header you want based on the if condition. I'm not sure about the syntax (but I'll check it for you) but it should be something like this:
@if(Auth::check())
    extends('headers.admin.blade.php')
@else
    extends('headers.guest.blade.php')
@endif

where headers is the name of the folder in /resources/views that you create, and it contains 2 blade templates: admin and guest.

The other solution is having one header, but the components are different. For example,You either want the login button, or you want the user's name. So in this case, inside the header you write:

@if(Auth::check( ))
    <div> {{ Auth::user->name }} </div>
@else
    <div> <button> Login </button> </div>
@endif

When you create a new Laravel project, you can check the default home page. It contains the logic for the second solution, and you can get the exact syntax from there to avoid any mistakes. You can also find it online (search for Laravel default home page).

Good luck, and tell me when it works.

Please or to participate in this conversation.