Laravel问题,未正确触发策略?

Laravel问题,未正确触发策略?,laravel,laravel-5,Laravel,Laravel 5,我有一个这样的路由模型绑定: Route::model('questionnaireAttachment', \App\Models\QuestionnaireAttachment::class); 我还在AuthServiceProvider.php中注册了策略: QuestionnaireAttachment::class => QuestionnaireAttachmentPolicy::class, 我的路线是这样的: Route::get('questionnaire/att

我有一个这样的路由模型绑定:

Route::model('questionnaireAttachment', \App\Models\QuestionnaireAttachment::class);
我还在AuthServiceProvider.php中注册了策略:

QuestionnaireAttachment::class => QuestionnaireAttachmentPolicy::class,
我的路线是这样的:

Route::get('questionnaire/attachments/{questionnaireAttachment}', [
    AttachmentController::class,
    'getAttachments'
])
->name('questionnaireAttachmentRetrieve')
->middleware('can:view,questionnaireAttachment');
策略返回错误;在它里面,我知道它失败了,但是当我向端点发出请求时,尽管返回false;我仍然可以到达控制器,得到有效的200响应

 public function getAttachments(QuestionnaireAttachment $attachment): \Symfony\Component\HttpFoundation\StreamedResponse
        {
            $file = Storage::disk('local')->exists("{$attachment->path}/{$attachment->filename}");
            if (!$file) {
                return Storage::disk('s3')->download("{$attachment->path}/{$attachment->filename}", $attachment->filename);
            }
            return Storage::disk('local')->download("{$attachment->path}/{$attachment->filename}", $attachment->filename);
        }

能否添加
AttachmentController::getAttachments()方法的标题?是否键入提示
questionnareattachment
作为参数?完成后,请检查编辑的问题谢谢您展开问题。您可以为
问题重新连接策略->视图()添加代码吗?
?您是否指定了任何可能覆盖单个策略的
检查之前的
或之后的
。有一个before方法检查用户角色是否为1,但它不是