getPDO(); $isConnected = (bool) DB::connection()->getDatabaseName(); if (! $isConnected) { return false; } $hasTable = Schema::hasTable('admins'); if (! $hasTable) { return false; } $userCount = DB::table('admins')->count(); if (! $userCount) { return false; } return true; } catch (Exception $e) { return false; } } /** * Drop all the tables and migrate in the database * * @return void|string */ public function migration() { try { Artisan::call('migrate:fresh'); } catch (Exception $e) { return response()->json([ 'error' => $e->getMessage(), ], 500); } } /** * Seed the database. * * @return void|string */ public function seeder($data) { $data['parameter'] = [ 'default_locale' => $data['parameter']['default_locales'], 'allowed_locales' => $data['parameter']['allowed_locales'], 'default_currency' => $data['parameter']['default_currency'], 'allowed_currencies' => $data['parameter']['allowed_currencies'], 'skip_admin_creation' => $data['parameter']['skip_admin_creation'], ]; try { app(BagistoDatabaseSeeder::class)->run($data['parameter']); $this->storageLink(); } catch (Exception $e) { return $e->getMessage(); } } /** * Storage Link. */ private function storageLink() { Artisan::call('storage:link'); } /** * Generate New Application Key */ public function generateKey() { try { Artisan::call('key:generate'); } catch (Exception $e) { } } /** * Generate fake product data. * * @return void|string */ public function seedSampleProducts($parameters) { try { app(ProductTableSeeder::class)->run($parameters); } catch (Exception $e) { return response()->json([ 'error' => $e->getMessage(), ], 500); } } }