Laravel ACL:未读取策略类

时间:2015-10-30 14:46:54

标签: acl laravel-5.1 policy

所以在AuthServiceProvider我正在做以下事情:

namespace App\Providers;

use Illuminate\Contracts\Auth\Access\Gate as GateContract;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;


class AuthServiceProvider extends ServiceProvider
{
    /**
     * The policy mappings for the application.
     *
     * @var array
     */
    protected $policies = [
        \App\Post::class => PostPolicy::class
    ];

    /**
     * Register any application authentication / authorization services.
     *
     * @param  \Illuminate\Contracts\Auth\Access\Gate  $gate
     * @return void
     */
    public function boot(GateContract $gate)
    {
        parent::registerPolicies($gate);

    }

PostPolicy

namespace App\Policies;

use App\Post;
use App\User;

class PostPolicy
{
    /**
     * Create a new policy instance.
     *
     * @return void
     */
    public function __construct()
    {
    }
    public function view(User $user)
    {
        dd('he was here');//This line NEVER gets executed.
        return $user->type === 'user';
    }
}

0 个答案:

没有答案