Laravel authorization example

Policy là các class quản lý tối ưu trong phân quyền thúc đẩy đến một Model hoặc tài nguyên nào đó. Ví dụ, nếu chương trình của bạn là một blog, bạn có thể sở hữu một model Post và một policy là postpolicy để phân quyền các hành động người dùng như tạo hay cập nhật các nội dung bài viết. Một policy muốn dùng cần phải được đăng ký, AuthServiceProvider được đưa vào trong project Laravel chứa một thuộc tính policies để map Eloquent model với các policy tương ứng với Laravel authorization example.
<?php

namespace AppProviders;

use AppPost;
use AppPoliciesPostPolicy;
use IlluminateSupportFacadesGate;
use IlluminateFoundationSupportProvidersAuthServiceProvider as ServiceProvider;

class AuthServiceProvider extends ServiceProvider

    /**
     * The policy mappings for the application.
     *
     * @var array
     */
    protected $policies = [
        Post::class => PostPolicy::class,
    ];

    /**
     * Register any application authentication / authorization services.
     *
     * @return void
     */
    public function boot()
    
        $this->registerPolicies();

        //
    
Laravel authorization example
5/5 - (1 vote)

Laravel authorization example - Khái niệm chi tiết về LA

Lê Trương Tấn Lộc (sieutocviet.page)

Với hơn 3 năm kinh nghiệm CSS, JS 7 năm kinh nghiệm trong quản trị website tư vấn giải pháp SEO từ khóa, Digital marketing tối ưu nhất cho tập đoàn quốc tế.
Hiện giữ chức vụ leader kinh doanh tại Siêu Tốc Việt.