%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /var/www/html/klinisol/klinisol-api/app/Console/Commands/
Upload File :
Create Path :
Current File : /var/www/html/klinisol/klinisol-api/app/Console/Commands/RunMigrationsCommand.php

<?php

namespace App\Console\Commands;

use App\Models\Department;
use App\Tenancy;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Artisan;

class RunMigrationsCommand extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'klinisol:migrations';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Run migrations for all klinisol clients';


    /**
     * Execute the console command.
     *
     * @return int
     */
    public function handle()
    {
        $departments = Department::on('klinisol_main')
                                 ->get();
        /** @var Department $department */
        foreach ($departments as $department) {
            \Log::channel('klinisol_migrations')->info("Migrating for $department->database");
            Tenancy::setDBConnection($department);
            Artisan::call('migrate', [
                '--path'     => 'database/migrations',
                '--force'    => true,
            ]);
            \Log::channel('klinisol_migrations')->info("Migrate finished for $department->database");
        }
    }
}

Zerion Mini Shell 1.0