AdminLTEAdmin.php 1.2 KB
Newer Older
jhon committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
<?php

namespace Acacha\AdminLTETemplateLaravel\Console;

use Illuminate\Console\Command;

/**
 * Class AdminLTEAdmin.
 */
class AdminLTEAdmin extends Command
{
    use HasUsername, HasEmail;

    /**
     * The name and signature of the console command.
     */
    protected $signature = 'adminlte-laravel:admin';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Create a seed for admin user and execute seed';

    /**
     * Execute the console command.
     */
    public function handle()
    {
        $this->call('make:adminUserSeeder');
        exec('composer dumpautoload 2>&1');
        sleep(3);
        $this->call('db:seed', [
            '--class' => basename(config('AdminUserSeeder', 'AdminUserSeeder.php'), ".php")
        ]);
        $this->info('User ' . $this->username() . '(' . $this->email() . ') ' .
            $this->passwordInfo() . ' created succesfully!');
    }

    /**
     * Get password info.
     */
    protected function passwordInfo()
    {
        if (env('ADMIN_PWD', '123456') == '123456') {
            return 'with password 123456';
        }
        return 'with the environemnt password (env var ADMIN_PWD)';
    }
}