PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, November 16, 2022

[FIXED] How to use One view with Multiple Guards Laravel

 November 16, 2022     laravel, laravel-5, laravel-6, laravel-7, laravel-views     No comments   

Issue

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

Solution

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


Answered By - mchljams
Answer Checked By - Timothy Miller (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing