diff --git a/app/Http/Controllers/Admin/SettingsController.php b/app/Http/Controllers/Admin/SettingsController.php index c9076e0c..875f29b1 100644 --- a/app/Http/Controllers/Admin/SettingsController.php +++ b/app/Http/Controllers/Admin/SettingsController.php @@ -35,10 +35,10 @@ class SettingsController extends BaseController */ public function update(Setting $setting, Request $request) { - $/*this->validate($request, Setting::$rules, Setting::$messages); + /*$this->validate($request, Setting::$rules, Setting::$messages); $this->updateEntry($setting, $request->all());*/ - return redirect("/admin/settings"); + return redirect('/admin/settings'); } } diff --git a/app/Models/Migrations/Migration.php b/app/Models/Migrations/Migration.php index cc7fe4b0..8b239496 100644 --- a/app/Models/Migrations/Migration.php +++ b/app/Models/Migrations/Migration.php @@ -21,7 +21,7 @@ class Migration extends MigrationBase try { DB::table($table)->insert($row); } catch (Exception $e) { - # setting already exists + # setting already exists, just ignore it if ($e->getCode() === 23000) { continue; } diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 7feb39e6..1fc113ab 100755 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -4,6 +4,7 @@ namespace App\Providers; use Illuminate\Support\Facades\Schema; use Illuminate\Support\ServiceProvider; +use App\Repositories\SettingRepository; class AppServiceProvider extends ServiceProvider @@ -15,6 +16,8 @@ class AppServiceProvider extends ServiceProvider { Schema::defaultStringLength(191); + $this->app->bind('setting', SettingRepository::class); + //\VaCentral\VaCentral::setVaCentralUrl(config('phpvms.vacentral_api_url')); if(!empty(config('phpvms.vacentral_api_key'))) { \VaCentral\VaCentral::setApiKey(config('phpvms.vacentral_api_key')); diff --git a/app/Repositories/SettingRepository.php b/app/Repositories/SettingRepository.php new file mode 100644 index 00000000..5164b5a5 --- /dev/null +++ b/app/Repositories/SettingRepository.php @@ -0,0 +1,32 @@ +get($key); + } else { + $settingRepo->set($key, $value); + } + } +} diff --git a/composer.json b/composer.json index a5c49c52..2a97473d 100755 --- a/composer.json +++ b/composer.json @@ -63,6 +63,9 @@ "bpocallaghan/generators": "5.0.1" }, "autoload": { + "files": [ + "app/Support/helpers.php" + ], "classmap": [ "database" ], diff --git a/database/migrations/2017_12_10_014930_create_settings_table.php b/database/migrations/2017_12_10_014930_create_settings_table.php index b7de5d51..0cb46837 100644 --- a/database/migrations/2017_12_10_014930_create_settings_table.php +++ b/database/migrations/2017_12_10_014930_create_settings_table.php @@ -15,11 +15,11 @@ class CreateSettingsTable extends Migration Schema::create('settings', function (Blueprint $table) { $table->increments('id'); $table->integer('order')->default(1); - $table->string('name')->default(''); + $table->string('name'); $table->string('key'); $table->string('value'); - $table->string('group')->default('general'); - $table->text('type')->default('text'); + $table->string('group')->nullable(); + $table->text('type')->nullable(); $table->text('options')->nullable(); $table->text('description')->nullable(); $table->timestamps();