File tree Expand file tree Collapse file tree 4 files changed +12
-4
lines changed
Expand file tree Collapse file tree 4 files changed +12
-4
lines changed Original file line number Diff line number Diff line change 66 'policies ' => (object ) [],
77 ]);
88} else {
9- collect (glob (base_path ('**/Models/*.php ' )))->each (fn ($ file ) => include_once ($ file ));
9+ collect (\Illuminate \Support \Facades \File::allFiles (base_path ('app/Models ' )))
10+ ->filter (fn (\Symfony \Component \Finder \SplFileInfo $ file ) => $ file ->getExtension () === 'php ' )
11+ ->each (fn ($ file ) => include_once ($ file ));
1012
1113 $ modelPolicies = collect (get_declared_classes ())
1214 ->filter (fn ($ class ) => is_subclass_of ($ class , \Illuminate \Database \Eloquent \Model::class))
Original file line number Diff line number Diff line change @@ -54,7 +54,9 @@ public function __construct(protected $factory)
5454
5555 public function all ()
5656 {
57- collect (glob (base_path ('**/Models/*.php ' )))->each (fn ($ file ) => include_once ($ file ));
57+ collect (\Illuminate \Support \Facades \File::allFiles (base_path ('app/Models ' )))
58+ ->filter (fn (\Symfony \Component \Finder \SplFileInfo $ file ) => $ file ->getExtension () === 'php ' )
59+ ->each (fn ($ file ) => include_once ($ file ));
5860
5961 return collect (get_declared_classes ())
6062 ->filter (fn ($ class ) => is_subclass_of ($ class , \Illuminate \Database \Eloquent \Model::class))
Original file line number Diff line number Diff line change @@ -6,7 +6,9 @@ if (!\\Illuminate\\Support\\Facades\\App::bound('auth')) {
66 'policies' => (object) [],
77 ]);
88} else {
9- collect(glob(base_path('**/Models/*.php')))->each(fn($file) => include_once($file));
9+ collect(\\Illuminate\\Support\\Facades\\File::allFiles(base_path('app/Models')))
10+ ->filter(fn(\\Symfony\\Component\\Finder\\SplFileInfo $file) => $file->getExtension() === 'php')
11+ ->each(fn($file) => include_once($file));
1012
1113 $modelPolicies = collect(get_declared_classes())
1214 ->filter(fn($class) => is_subclass_of($class, \\Illuminate\\Database\\Eloquent\\Model::class))
Original file line number Diff line number Diff line change @@ -54,7 +54,9 @@ $models = new class($factory) {
5454
5555 public function all()
5656 {
57- collect(glob(base_path('**/Models/*.php')))->each(fn($file) => include_once($file));
57+ collect(\\Illuminate\\Support\\Facades\\File::allFiles(base_path('app/Models')))
58+ ->filter(fn(\\Symfony\\Component\\Finder\\SplFileInfo $file) => $file->getExtension() === 'php')
59+ ->each(fn($file) => include_once($file));
5860
5961 return collect(get_declared_classes())
6062 ->filter(fn($class) => is_subclass_of($class, \\Illuminate\\Database\\Eloquent\\Model::class))
You can’t perform that action at this time.
0 commit comments