如何在流明中使用授权

时间:2018-04-10 08:35:21

标签: lumen

我遵循了这个文档。 https://lumen.laravel.com/docs/5.5/authorization

其实我不知道在哪里定义门 在register()boot()函数

之后也说:Class 'App\Providers\Gate' not found 其中3个中的正确答案是什么?

  

照亮\验证\存取\门

     

照亮\支持\外墙\门

     

照亮\合同\验证\存取\门

对于'检查能力',文件说: if (Gate::allows('update-post', $post)) {

但是我不能在我的路线文件中使用它。 这里的问题是如何在路线中使用闸门?

请支持我。我对此很新。 感谢。

1 个答案:

答案 0 :(得分:0)

you should use this Illuminate\Support\Facades\Gate
**remember** everything that you use trough `::` like Gate::allows or  
Route::get or something like that is `Facade` so for import use the uri that 
contains `Facade`
Here is good tutorial which explain how to use `Gate`, hope it can be usefull
https://laravel-news.com/authorization-gates
https://code.tutsplus.com/tutorials/gates-and-policies-in-laravel--cms-29780
https://www.grafikart.fr/tutoriels/laravel/gates-policies-867