Laravel Gates Policies Middleware And Guards | Laravel Core Concepts | Laravel Basics | Ajay Yadav

Channel:
Subscribers:
16,000
Published on ● Video Link: https://www.youtube.com/watch?v=Yg2Q9_O1iJA



Duration: 7:31
12,715 views
0


In this video Understand Laravel Gates Policies Middleware And Guards in detail, Laravel basic and Laravel Core Concepts. And When And How Use Laravel Gates Policies Middleware And Guards.

Middleware:
Typically runs on a route (but you can also run it on controller methods) and can be used to filter or inspect incoming requests.
One example would be auth, which determines if the person trying to request a particular route is authenticated (logged in) to the system. Another example would be to check that a request has a specific header (e.g. if you want to check that the app is sending a X-MYAPP-CUSTOMHEADER header or something)

As mentioned, middleware can be defined on a route (e.g. in web.php or api.php) or in a controller.

Gates:
Gates are functions defined in your AuthServiceProvider.php file (in the App\Providers folder) and specify what a user is allowed to do and what they're not allowed to do.

Policies:
Policies work similarly to gates, but just apply to a specific model and are stored in their own file (in App\Policies)
You can create one by using php artisan make:policy PostPolicy -m Post. It'll create a file called PostPolicy.php which will create a bunch of functions:
viewAny // Can the user even look at this model? If no, they'll be denied for all the below methods
view // Can the user look at the specified Post?
create // Can they create a new Post
update // Can they edit / update the specified Post?
delete // Can they (soft) delete the specified Post?
restore // Can they restore the specified (soft) deleted Post?
forceDelete // Can they force delete the specified Post?


Guards:
Guards are a way to specify how users are authenticated for requests. They're the definition of how the system should store and retrieve information about your users.

You can find the configuration in your config/auth.php file. A web guard is the traditional cookie store - so that web guard instructs Laravel to store and retrieve session information the classic way. The API guard, on the other hand, uses tokens. So you would use the API guard if you want to authenticate users and requests using an API token in the header (bearer) or query parameter.





Gates and Plicies video :
https://www.youtube.com/watch?v=HPLBDrrzZcU

Admin And User Login :(Multi Auth - Guards )
https://www.youtube.com/watch?v=UWniysfpTmM


Our Playlist:
Computer Facts:https://www.youtube.com/playlist?list=PLT51dtioU1pMRgv8kNYajmgJfA1W1zwqv

Laravel User Management System :
https://www.youtube.com/playlist?list=PLT51dtioU1pPNxwwo3dWfkUCKI2BXnc_H

Laravel Auth System :
https://www.youtube.com/playlist?list=PLT51dtioU1pPmtFnYQ5WRnYvvL1zW74wl

Laravel And Vuejs
https://www.youtube.com/playlist?list=PLT51dtioU1pN0mQqQ5RM5nE8uOfzsqml2

Laravel Eloquent Relationships
https://www.youtube.com/playlist?list=PLT51dtioU1pO7YgLOyNY0KF_3ny79D0BV

GitHub Link :
https://github.com/ajayyadavexpo/InertiaTodo


#GatesVsPolicies #MiddlewareVsGuards #LaravelCoreConcepts
Please subscribe to my channel and share the video with your friends.




Other Videos By Ajay yadav


2022-03-13Laravel 9 CRUD Tutorial For Beginners | Laravel 9 Step By Step | Laravel 9 Tutorial | Ajay Yadav
2022-03-10Laravel Comment System With Replies | Comment System With User Details | Nested Comments | Ajay
2022-03-06Laravel Model Scope | Local Scope | Global Scope | Laravel Query Builder | Laravel Scope |Ajay yadav
2022-03-03Laravel Nuxtjs Auth | Laravel Sanctum | Nuxtjs Authentication with Laravel Sanctum | Ajay
2022-02-27Laravel Observers and Laravel Model Events | Laravel 9 Observers | Laravel 9 Modal Events | Ajay
2022-02-24Laravel Nuxt JS Tailwind Todo List | CRUD With Laravel And Nuxt JS | Nuxt JS Laravel Tutorial | Ajay
2022-02-20Laravel Middleware | Why And How To Use Middleware In Laravel | Everything About Middleware | Ajay
2022-02-17Laravel Event And Listener | When and How to Use Event And Listener | Laravel 9 | Ajay Yadav
2022-02-13Laravel 9 New Enum Casting | Enum in PHP 8.1 | Laravel 9 New Updates | Laravel 9 New Features | Ajay
2022-02-10Send Real-Time Notification In Laravel And Vuejs | Real-Time Notification | Laravel Broadcast | Ajay
2022-02-06Laravel Gates Policies Middleware And Guards | Laravel Core Concepts | Laravel Basics | Ajay Yadav
2022-02-03Laravel API With React JS | Connect React Js with Laravel API | Laravel And React JS | Ajay yadav
2022-01-29Laravel 9 Accessors And Mutators | Laravel 9 New Updates | Laravel 9 Eloquent | Ajay yadav | HINDI
2022-01-27Laravel 9 New Error Page | Ignition Error Page | Laravel 9 Updates | Laravel News | Ajay Yadav
2022-01-23Inertiajs And Laravel Todo List | Inertiajs Tutorial | InertiaJs CRUD | InertiaJs Breeze In HINDI
2022-01-20How To Upload Image in Vue 3 And Laravel | Upload Image In Vue 3 | Vue 3 Image Upload [HINDI]
2022-01-16Laravel Accessor And Mutator | Accessor Vs Mutator Laravel | Getters And Setters | HINDI
2022-01-13Soft Deletes In Laravel | How To Use Soft Deletes In Laravel | Laravel Advanced Concepts | HINDI
2022-01-09Laravel Real Time Chat Application | Vue 3 Laravel Real-Time Chat | Laravel Broadcasting |HINDI
2022-01-06SMS Notification In Laravel | Send Notification on Mobile in Laravel | Laravel Notifications #Part 4
2022-01-02Laravel Slack Notificaton | Laravel Advanced | Laravel Notifications | Laravel Slack | Hindi #Part 3



Tags:
Understand Laravel Gates Policies Middleware And Guards
When And How Use Laravel
laravel gates vs middleware vs gates vs policies
gates vs policies vs middleware
guards vs middleware
guards vs middleware vs gates vs policies
laravel guards vs middleware vs gates
when to use guards
laravel guards middleware gates and policies
guards middleware and gates policies
when and how to use laravel gates and plicies middleware guards
laravel guards
laravel gates and policies