<?php

namespace App\Console\Commands;

use App\Models\Admin;
use App\Models\Setting;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Artisan;

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

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'prepare required commands for project';

    /**
     * Execute the console command.
     *
     * @return int
     */
    public function handle()
    {
        //add superadmin account if admins empty
        if(Admin::count() <= 0) {
            Artisan::call('db:seed', ['--class' => 'AdminSeeder']);
        }

        //add settings if setting empty
        if(Setting::count() <= 0) {
            Artisan::call('db:seed', ['--class' => 'SettingSeeder']);
        }

        Artisan::call('storage:link');
    }
}
