
Authorization & Policies
Gates, policies, model policies, @can directive, authorize method, middleware, role-based access
1What is a Gate in Laravel?
What is a Gate in Laravel?
Câu trả lời
A Gate is a simple closure that determines whether a user is authorized to perform a given action. Gates are defined in the AuthServiceProvider and allow centralizing authorization logic in a concise manner. They are particularly suited for one-off checks that are not tied to a specific model.
2What is a Policy in Laravel?
What is a Policy in Laravel?
Câu trả lời
A Policy is a class that organizes authorization logic around a specific Eloquent model or resource. It groups all authorization methods related to that model (viewAny, view, create, update, delete) in a single file, which improves the organization and maintainability of authorization code.
3How to define a Gate in the AuthServiceProvider?
How to define a Gate in the AuthServiceProvider?
Câu trả lời
Gates are defined in the boot method of the AuthServiceProvider using the Gate facade with the define method. This method takes two arguments: the gate name and a closure that receives the authenticated user and returns a boolean indicating whether the action is authorized.
Which Artisan command creates a Policy?
What is the purpose of the @can directive in Blade views?
+15 câu hỏi phỏng vấn
Các chủ đề phỏng vấn Laravel khác
PHP Basics
PHP OOP Essentials
Composer & Autoloading
Laravel Fundamentals
Laravel Routing
Blade Templates
Request & Response
Eloquent ORM Basics
Eloquent Relationships
Migrations & Schema Builder
Validation & Forms
Authentication
API Resources & Authentication
Middleware
Service Container & DI
Queues & Jobs
Events & Listeners
Notifications & Mail
File Storage
Testing & PHPUnit
Caching
Livewire & Inertia
Eloquent Advanced
Repository Pattern
Laravel Packages
Performance Optimization
Security Best Practices
Laravel Octane
Laravel Distributed Systems
Observability & Monitoring
Deployment & DevOps
Nắm vững Laravel cho lần phỏng vấn tiếp theo
Truy cập tất cả câu hỏi, flashcards, bài kiểm tra kỹ thuật, bài tập code review và mô phỏng phỏng vấn.
Bắt đầu miễn phí