Answers for "policy usage in laravel"

PHP
3

laravel policy create

php artisan make:policy PostPolicy --model=Post
Posted by: Guest on April-11-2021
0

policy usage in laravel

<?php

namespace App\Providers;

use App\Post;
use App\Policies\PostPolicy;
use Illuminate\Support\Facades\Gate;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider 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();

        //
    }
}
Posted by: Guest on March-11-2021

Browse Popular Code Answers by Language