<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\Artisan;

class CreateFreshCommand extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'app:generate-fresh';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';

    /**
     * Execute the console command.
     */
    public function handle()
    {
        $this->info('Migration started..');

        $migrate = Artisan::call('migrate:fresh --seed');

        $this->info('Migrate successfully.');

        $this->info('Permission started..');
        Artisan::call('permission:create-permission-routes');
        $this->info('Permission successfully.');

        $this->info('Seeder started..');
        Artisan::call('db:seed', [
            '--class' => 'GenerateFreshSeeder',
            '--force' => true
        ]);
        $this->info('Seeder successfully.');
    }
}