Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto generate models #1163

Merged
merged 9 commits into from
Mar 15, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions config/ide-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,12 +280,12 @@

/*
|--------------------------------------------------------------------------
| Generate model helpers after migrations
| Run artisan command(s) after migrations to generate model helpers
|--------------------------------------------------------------------------
|
| Set to false to disable running ide-helper:models after a successful
| migration command or specify the parameters in either string or array form.
| e.g, specifying `--nowrite` will execute `php artisan ide-helper:models --nowrite`
| Set to false to disable this feature or specify the command(s).
| E.g. `ide-helper:models --nowrite`.
| If an array is provided each element will be executed in order.
|
*/
'post_migrate' => false,
Expand Down
12 changes: 6 additions & 6 deletions src/Listeners/GenerateModelHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Illuminate\Console\Events\CommandFinished;
use Illuminate\Contracts\Config\Repository as Config;
use Illuminate\Contracts\Console\Kernel as Artisan;
use Illuminate\Support\Arr;

class GenerateModelHelper
{
Expand Down Expand Up @@ -45,11 +46,10 @@ public function handle(CommandFinished $event)

self::$shouldRun = false;

$parameters = $this->config->get('ide-helper.post_migrate');
$this->artisan->call(
is_array($parameters) ? 'ide-helper:models' : 'ide-helper:models ' . $parameters,
is_array($parameters) ? $parameters : [],
$event->output,
);
$commands = $this->config->get('ide-helper.post_migrate');

foreach (Arr::wrap($commands) as $command) {
mfn marked this conversation as resolved.
Show resolved Hide resolved
$this->artisan->call($command, [], $event->output);
}
}
}