Issues (14)

src/Commands/Migrate.php (1 issue)

Labels
Severity
1
<?php
2
namespace Prateekkarki\Laragen\Commands;
3
4
use Illuminate\Console\Command;
5
use Artisan;
6
7
class Migrate extends Command
8
{
9
    /**
10
     * The name and signature of the console command.
11
     *
12
     * @var string
13
     */
14
    protected $signature = 'laragen:migrate';
15
16
    /**
17
     * The console command description.
18
     *
19
     * @var string
20
     */
21
    protected $description = 'Laragen Migrate Database for your project';
22
23
    /**
24
     * Execute the console command.
25
     *
26
     * @return mixed
27
     */
28
    public function handle()
29
    {
30
        Artisan::call('migrate:fresh');
31
        $this->line(Artisan::output());
32
33
        $migrationDirs = [
34
            'laragenDir' => 'laragen/database/migrations',
35
            'laravelDir' => 'database/migrations/laragen'
36
        ];
37
38
        foreach ($migrationDirs as $dir) {
39
            if(is_dir(base_path($dir)) && count(glob( base_path($dir) . '*', GLOB_MARK ))){
0 ignored issues
show
It seems like glob(base_path($dir) . '...gen\Commands\GLOB_MARK) can also be of type false; however, parameter $var of count() does only seem to accept Countable|array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

39
            if(is_dir(base_path($dir)) && count(/** @scrutinizer ignore-type */ glob( base_path($dir) . '*', GLOB_MARK ))){
Loading history...
40
                Artisan::call('migrate', [
41
                    '--path' => $dir
42
                ]);
43
                $this->line(Artisan::output());
44
            }
45
        }
46
    }
47
}
48