| Conditions | 3 |
| Paths | 2 |
| Total Lines | 26 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 34 | protected function loadGates() |
||
| 35 | { |
||
| 36 | $paths = array_filter(config('gates.paths'), function ($path) { |
||
| 37 | return is_dir($path); |
||
| 38 | }); |
||
| 39 | |||
| 40 | $files = ! empty($paths) ? (new Finder)->in($paths)->files() : []; |
||
| 41 | |||
| 42 | collect($files) |
||
| 43 | ->map(function ($file) { |
||
| 44 | return str_replace( |
||
| 45 | ['/', '.php'], |
||
| 46 | ['\\', ''], |
||
| 47 | Str::ucfirst(Str::after($file->getPathname(), realpath(base_path()).DIRECTORY_SEPARATOR)) |
||
| 48 | ); |
||
| 49 | }) |
||
| 50 | ->merge(config('gates.classes')) |
||
| 51 | ->unique() |
||
| 52 | ->filter(function ($class) { |
||
| 53 | return in_array(HasGates::class, class_uses_recursive($class)) |
||
| 54 | && ! (new \ReflectionClass($class))->isAbstract(); |
||
| 55 | }) |
||
| 56 | ->each(function ($class) { |
||
| 57 | $class::gateRegister(); |
||
| 58 | }); |
||
| 59 | } |
||
| 60 | } |
||
| 61 |