diff --git a/src/Illuminate/Database/Console/PruneCommand.php b/src/Illuminate/Database/Console/PruneCommand.php index 0c51beb345b..65ac612167d 100644 --- a/src/Illuminate/Database/Console/PruneCommand.php +++ b/src/Illuminate/Database/Console/PruneCommand.php @@ -25,7 +25,8 @@ class PruneCommand extends Command {--model=* : Class names of the models to be pruned} {--except=* : Class names of the models to be excluded from pruning} {--chunk=1000 : The number of models to retrieve per chunk of models to be deleted} - {--pretend : Display the number of prunable records found instead of deleting them}'; + {--pretend : Display the number of prunable records found instead of deleting them} + {--path=* : Absolute path(s) to directories where models are located}'; /** * The console command description. @@ -125,7 +126,7 @@ protected function models() throw new InvalidArgumentException('The --models and --except options cannot be combined.'); } - return collect((new Finder)->in($this->getDefaultPath())->files()->name('*.php')) + return collect((new Finder)->in($this->getPath())->files()->name('*.php')) ->map(function ($model) { $namespace = $this->laravel->getNamespace(); @@ -146,12 +147,16 @@ protected function models() } /** - * Get the default path where models are located. + * Get the path where models are located. * * @return string|string[] */ - protected function getDefaultPath() + protected function getPath() { + if (! empty($path = $this->option('path'))) { + return $path; + } + return app_path('Models'); }