app/Console/Commands/dbcreate.php
/**
     * Execute the console command.
     *
     * @return int
     */
Execute the console command.
@return int
Execute the console command . @return int
public function handle()
    {
        $schemaName = $this->argument('name') ?: config('database.connections.mysql.database');
        $charset = config('database.connections.mysql.charset', 'utf8mb4');
        $collation = config('database.connections.mysql.collation', 'utf8mb4_unicode_ci');
        config(['database.connections.mysql.database' => null]);
        $query = "DROP DATABASE $schemaName; ";
        DB::statement($query);
        $query = "CREATE DATABASE IF NOT EXISTS $schemaName CHARACTER SET $charset COLLATE $collation; ";
        DB::statement($query);
        echo "Database $schemaName created successfully";
        config(['database.connections.mysql.database' => $schemaName]);
    }
public function handle ( ) { $ schemaName = $ this -> argument ( 'name' ) ? : config ( 'database.connections.mysql.database' ) ; $ charset = config ( 'database.connections.mysql.charset' , 'utf8mb4' ) ; $ collation = config ( 'database.connections.mysql.collation' , 'utf8mb4_unicode_ci' ) ; config ( [ 'database.connections.mysql.database' => null ] ) ; $ query = " DROP DATABASE  $ schemaName ;  " ; DB :: statement ( $ query ) ; $ query = " CREATE DATABASE IF NOT EXISTS  $ schemaName  CHARACTER SET  $ charset  COLLATE  $ collation ;  " ; DB :: statement ( $ query ) ; echo " Database  $ schemaName  created successfully " ; config ( [ 'database.connections.mysql.database' => $ schemaName ] ) ; }
Execute the console command.
Execute the console command .