Laravel authorization example

Policy là các class quản lý tuyệt vời trong phân quyền ảnh hưởng đến một Model hoặc tài nguyên nào đó. Ví dụ, nếu phần mềm của bạn là một blog, bạn thường xuyên nắm tới một model Post và một policy là postpolicy để phân quyền các hành động người mua như là tạo hay cập nhật các bài viết. Một policy muốn dùng nên đượ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 bình chọn)

Laravel authorization ví dụ - Định nghĩa dễ hiểu về LA

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

Có hơn 6 năm thực chiến Python, PHP 8 năm kinh nghiệm trong quản trị website tư vấn giải pháp SEO từ khóa, Marketing tối ưu nhất cho tập đoàn quốc tế.
Hiện làm quản lý kinh doanh tại Siêu Tốc Việt.