Run a Migration by passing parameters on Laravel 5

Asked

Viewed 87 times

1

I am creating a robust application where I will define which commands will be executed within a database according to the subdomain (which is also the name of the client’s database). How can I pass this parameter to an Laravel Migration? I’m looking for something like this:

<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateDb extends Migration{

    public function up($dbname){
        DB::select( DB::raw( 'CREATE DATABASE :db', ['db'=>$dbname] ) );
    }

    public function down($dbname){
        DB::select( DB::raw( 'DROP DATABASE :db', ['db'=>$dbname] ) );
    }

}
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.