/* Decoded by unphp.net */ , September 2018 */ namespace App\Http\Controllers\Installer\Helpers; use Exception; use Illuminate\Database\SQLiteConnection; use Illuminate\Support\Facades\Artisan; use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\DB; use Symfony\Component\Console\Output\BufferedOutput; class DatabaseManager { public function migrateAndSeed() { $outputLog = new BufferedOutput(); $this->sqlite($outputLog); return $this->migrate($outputLog); } private function migrate($outputLog) { try { Artisan::call("migrate", ["--force" => true], $outputLog); } catch (Exception $e) { return $this->response($e->getMessage(), "error", $outputLog); } return $this->seed($outputLog); } private function seed($outputLog) { try { Artisan::call("db:seed", ["--force" => true], $outputLog); Artisan::call("incevio:generate-key", ["--force" => true], $outputLog); } catch (Exception $e) { return $this->response($e->getMessage(), "error", $outputLog); } return $this->response(trans("installer_messages.final.finished"), "success", $outputLog); } public function seedDemoData() { ini_set("max_execution_time", 1200); $outputLog = new BufferedOutput(); try { Artisan::call("incevio:demo"); } catch (Exception $e) { return $this->response($e->getMessage(), "error", $outputLog); } return $this->response(trans("installer_messages.final.finished"), "success", $outputLog); } private function response($message, $status, $outputLog) { return ["status" => $status, "message" => $message, "dbOutputLog" => $outputLog->fetch()]; } private function sqlite($outputLog) { if (!DB::connection() instanceof SQLiteConnection) { goto lEmKz; } $database = DB::connection()->getDatabaseName(); if (file_exists($database)) { goto Ada_H; } touch($database); DB::reconnect(Config::get("database.default")); Ada_H: $outputLog->write("Using SqlLite database: " . $database, 1); lEmKz: } } ?>