Famdirksen /
roles
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Famdirksen\Roles; |
||
| 4 | |||
| 5 | use Illuminate\Support\ServiceProvider; |
||
| 6 | |||
| 7 | class RolesServiceProvider extends ServiceProvider |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * Bootstrap any application services. |
||
| 11 | * |
||
| 12 | * @return void |
||
| 13 | */ |
||
| 14 | public function boot() |
||
| 15 | { |
||
| 16 | $this->publishes([ |
||
| 17 | __DIR__ . '/../config/roles.php' => config_path('roles.php'), |
||
| 18 | ], 'config'); |
||
| 19 | |||
| 20 | $this->publishes([ |
||
| 21 | __DIR__ . '/../migrations/' => base_path('/database/migrations'), |
||
| 22 | ], 'migrations'); |
||
| 23 | |||
| 24 | $this->registerBladeExtensions(); |
||
| 25 | } |
||
| 26 | |||
| 27 | /** |
||
| 28 | * Register any application services. |
||
| 29 | * |
||
| 30 | * @return void |
||
| 31 | */ |
||
| 32 | public function register() |
||
| 33 | { |
||
| 34 | $this->mergeConfigFrom(__DIR__ . '/../config/roles.php', 'roles'); |
||
|
0 ignored issues
–
show
|
|||
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * Register Blade extensions. |
||
| 39 | * |
||
| 40 | * @return void |
||
| 41 | */ |
||
| 42 | protected function registerBladeExtensions() |
||
| 43 | { |
||
| 44 | $blade = $this->app['view']->getEngineResolver()->resolve('blade')->getCompiler(); |
||
| 45 | |||
| 46 | $blade->directive('role', function ($expression) { |
||
| 47 | return "<?php if (Auth::check() && Auth::user()->hasRole({$expression})): ?>"; |
||
| 48 | }); |
||
| 49 | |||
| 50 | $blade->directive('endrole', function () { |
||
| 51 | return '<?php endif; ?>'; |
||
| 52 | }); |
||
| 53 | |||
| 54 | $blade->directive('permission', function ($expression) { |
||
| 55 | return "<?php if (Auth::check() && Auth::user()->hasPermission({$expression})): ?>"; |
||
| 56 | }); |
||
| 57 | |||
| 58 | $blade->directive('endpermission', function () { |
||
| 59 | return '<?php endif; ?>'; |
||
| 60 | }); |
||
| 61 | |||
| 62 | $blade->directive('level', function ($expression) { |
||
| 63 | $level = trim($expression, '()'); |
||
| 64 | |||
| 65 | return "<?php if (Auth::check() && Auth::user()->level() >= {$level}): ?>"; |
||
| 66 | }); |
||
| 67 | |||
| 68 | $blade->directive('endlevel', function () { |
||
| 69 | return '<?php endif; ?>'; |
||
| 70 | }); |
||
| 71 | |||
| 72 | $blade->directive('allowed', function ($expression) { |
||
| 73 | return "<?php if (Auth::check() && Auth::user()->allowed({$expression})): ?>"; |
||
| 74 | }); |
||
| 75 | |||
| 76 | $blade->directive('endallowed', function () { |
||
| 77 | return '<?php endif; ?>'; |
||
| 78 | }); |
||
| 79 | } |
||
| 80 | } |
||
| 81 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.