I am using Laravel Backpack for my admin part of the application. Right now after I create a "company" through my backend I call a function on the Company model to do these steps:
Create a new database with a name I pass it
Check the DB is made
Run all migrations from my Company folder
in my CrudController
$company->createDatabase( $request->input('db_name') );
in my Model
public function createDatabase($dbName)
{
//Create a new DB with the company db_name attribute
$new_db = DB::statement("CREATE DATABASE {$dbName}" );
//Now migrate over all Company specific migrations
if($new_db)
{
\App::make( 'setDbConnection', $dbName );
return Artisan::call( 'migrate', [
'--database' => $dbName,
'--path' => 'app/database/migrations/company',
]);
}
}
Right now I will create the new DB just fine but get errors running migrations.
If I have the \App::make( 'setDbConnection', $dbName ); in there I get:Application::make() must be of the type array, string given
If I take that out and just try a migration I get: Database [MyNewDBName] not configured.