for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace App\Http\Helpers\Installer;
use Exception;
use Illuminate\Database\SQLiteConnection;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\DB;
class DatabaseManager
{
/**
* Migrate and seed the database.
*
* @return array
*/
public function migrateAndSeed()
$this->sqlite();
return $this->migrate();
}
* Run the migration and call the seeder.
private function migrate()
try{
Artisan::call('migrate', ["--force"=> true ]);
catch(Exception $e){
return $this->response($e->getMessage());
return $this->seed();
* Seed the database.
private function seed()
Artisan::call('db:seed');
return $this->response(trans('installer.final.finished'), 'success');
* Return a formatted error messages.
* @param $message
* @param string $status
private function response($message, $status = 'danger')
return array(
'status' => $status,
'message' => $message
);
* check database type. If SQLite, then create the database file.
private function sqlite()
if(DB::connection() instanceof SQLiteConnection) {
$database = DB::connection()->getDatabaseName();
if(!file_exists($database)) {
touch($database);
DB::reconnect(Config::get('database.default'));