How to use One view with Multiple Guards Laravel

512 Views Asked by At

I have multiple guards in my system

Admin
User

Admin and User both can add the Organizations details but they have different template layout. What i'm doing now i create views of each guard like this

views
  user
    organizations
       index.blade.php
       _form.blade.php
       create.blade.php
       edit.blade.php
  admin
    organizations
       index.blade.php
       _form.blade.php
       create.blade.php
       edit.blade.php

Now i want to create one views which can be used by multiple guards with different layouts

views
   organizations
      index.blade.php
      _form.blade.php
      create.blade.php
      edit.blade.php
1

There are 1 best solutions below

2
mchljams On BEST ANSWER

From the Laravel Blade Documentation:

If needed, you may specify the authentication guard that should be checked when using the @auth and @guest directives:

@auth('admin')
    // The user is authenticated...
@endauth

@guest('admin')
    // The user is not authenticated...
@endguest