lundi 1 octobre 2018

How do I get this policy to work in Laravel?

I have a very basic policy

<?php

namespace App\Policies;

use App\Models\Comment;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;

class CommentPolicy
{
    use HandlesAuthorization;

    public function update(User $user, Comment $comment)
    {
        return true;
    }
}

I call it in a view

@can('update', $comment)
Edit
@endcan

I register it

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

Even though it should always show because I've hardcoded true, nothing shows



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire