No video

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

  Рет қаралды 13,199

Ajay yadav

Ajay yadav

Күн бұрын

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 :
• Video
Admin And User Login :(Multi Auth - Guards )
• Laravel Admin And User...
Our Playlist:
Computer Facts: • Computer facts
Laravel User Management System :
• Laravel User Managemen...
Laravel Auth System :
• Laravel Multi Auth System
Laravel And Vuejs
• Laravel And Vuejs
Laravel Eloquent Relationships
• Laravel Eloquent Relat...
GitHub Link :
github.com/aja...
#GatesVsPolicies #MiddlewareVsGuards #LaravelCoreConcepts
Please subscribe to my channel and share the video with your friends.

Пікірлер: 14
Yummy Lifehack 😋 @artur-boy
00:19
Andrey Grechka
Рет қаралды 4,5 МЛН
王子原来是假正经#艾莎
00:39
在逃的公主
Рет қаралды 25 МЛН
Gates (Permissions and Roles) | Laravel 10 Tutorial #36
16:09
Laravel: 3 Places to Check Gates or Permissions
4:24
Laravel Daily
Рет қаралды 9 М.
Gates Authorization in Laravel (Hindi)
33:31
Geeky Shows
Рет қаралды 10 М.
HOC Pattern in React
20:51
Cosden Solutions
Рет қаралды 7 М.