diff --git a/app/Services/PluginManager.php b/app/Services/PluginManager.php index 97b14e6c..ddf7535b 100644 --- a/app/Services/PluginManager.php +++ b/app/Services/PluginManager.php @@ -213,7 +213,7 @@ class PluginManager */ public function getEnabled() { - return json_decode($this->option->get('plugins_enabled'), true); + return (array) json_decode($this->option->get('plugins_enabled'), true); } /** diff --git a/app/Services/Repositories/OptionRepository.php b/app/Services/Repositories/OptionRepository.php index e2acc5b0..1a006d4d 100644 --- a/app/Services/Repositories/OptionRepository.php +++ b/app/Services/Repositories/OptionRepository.php @@ -4,6 +4,7 @@ namespace App\Services\Repositories; use DB; use Illuminate\Support\Arr; +use Illuminate\Database\QueryException; class OptionRepository extends Repository { @@ -21,7 +22,11 @@ class OptionRepository extends Repository */ public function __construct() { - $options = DB::table('options')->get(); + try { + $options = DB::table('options')->get(); + } catch (QueryException $e) { + $options = []; + } foreach ($options as $option) { $this->items[$option->option_name] = $option->option_value; @@ -75,15 +80,19 @@ class OptionRepository extends Repository { $this->items_modified = array_unique($this->items_modified); - foreach ($this->items_modified as $key) { - if (!DB::table('options')->where('option_name', $key)->first()) { - DB::table('options') - ->insert(['option_name' => $key, 'option_value' => $this[$key]]); - } else { - DB::table('options') - ->where('option_name', $key) - ->update(['option_value' => $this[$key]]); + try { + foreach ($this->items_modified as $key) { + if (!DB::table('options')->where('option_name', $key)->first()) { + DB::table('options') + ->insert(['option_name' => $key, 'option_value' => $this[$key]]); + } else { + DB::table('options') + ->where('option_name', $key) + ->update(['option_value' => $this[$key]]); + } } + } catch (QueryException $e) { + return; } } diff --git a/setup/includes/bootstrap.php b/setup/includes/bootstrap.php index 9aaedaaf..55092c1c 100644 --- a/setup/includes/bootstrap.php +++ b/setup/includes/bootstrap.php @@ -83,7 +83,7 @@ $app->bind('url', function ($app) { $app->instance('request', $request); $app->singleton('database', App\Services\Database\Database::class); -$app->singleton('option', App\Services\OptionRepository::class); +$app->singleton('option', App\Services\Repositories\OptionRepository::class); View::addExtension('tpl', 'blade');