File tree Expand file tree Collapse file tree 2 files changed +19
-7
lines changed
src/Illuminate/Database/Console Expand file tree Collapse file tree 2 files changed +19
-7
lines changed Original file line number Diff line number Diff line change @@ -115,18 +115,19 @@ protected function pruneModel(string $model)
115
115
*/
116
116
protected function models ()
117
117
{
118
- if (! empty ($ models = $ this ->option ('model ' ))) {
119
- return (new Collection ($ models ))->filter (function ($ model ) {
120
- return class_exists ($ model );
121
- })->values ();
122
- }
123
-
118
+ $ models = $ this ->option ('model ' );
124
119
$ except = $ this ->option ('except ' );
125
120
126
- if (! empty ( $ models) && ! empty ( $ except) ) {
121
+ if ($ models && $ except ) {
127
122
throw new InvalidArgumentException ('The --models and --except options cannot be combined. ' );
128
123
}
129
124
125
+ if ($ models ) {
126
+ return (new Collection ($ models ))
127
+ ->filter (static fn (string $ model ) => class_exists ($ model ))
128
+ ->values ();
129
+ }
130
+
130
131
return (new Collection (Finder::create ()->in ($ this ->getPath ())->files ()->name ('*.php ' )))
131
132
->map (function ($ model ) {
132
133
$ namespace = $ this ->laravel ->getNamespace ();
Original file line number Diff line number Diff line change @@ -39,6 +39,17 @@ protected function setUp(): void
39
39
$ container ->alias (DispatcherContract::class, 'events ' );
40
40
}
41
41
42
+ public function testPrunableModelAndExceptWithEachOther (): void
43
+ {
44
+ $ this ->expectException (\InvalidArgumentException::class);
45
+ $ this ->expectExceptionMessage ('The --models and --except options cannot be combined. ' );
46
+
47
+ $ this ->artisan ([
48
+ '--model ' => Pruning \Models \PrunableTestModelWithPrunableRecords::class,
49
+ '--except ' => Pruning \Models \PrunableTestModelWithPrunableRecords::class,
50
+ ]);
51
+ }
52
+
42
53
public function testPrunableModelWithPrunableRecords ()
43
54
{
44
55
$ output = $ this ->artisan (['--model ' => Pruning \Models \PrunableTestModelWithPrunableRecords::class]);
You can’t perform that action at this time.
0 commit comments