我有一个非常基本的政策
<?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;
}
}
我在一个视图中调用它
@can('update', $comment)
Edit
@endcan
我注册
class AuthServiceProvider extends ServiceProvider
{
/**
* The policy mappings for the application.
*
* @var array
*/
protected $policies = [
App\Models\Comment::class => App\Policies\CommentPolicy::class,
];
即使它应该总是显示,因为我已经硬编码true
,但没有显示