/** * Run the migrations. */ public function up() { Schema::create('themes_setting_key_types', function (Blueprint $table) { $table->increments('id'); $table->string('name'); }); $names = ['boolean', 'string', 'text', 'numeric', 'select']; foreach ($names as $name) { ThemeSettingType::create(['name' => $name]); } Schema::create('themes_setting_keys', function (Blueprint $table) { $table->increments('id'); $table->integer('type_id', false, true); $table->foreign('type_id', 'theme_setting_keys_to_key_type')->references('id')->on('themes_setting_key_types')->onDelete('cascade'); $table->integer('theme_id', false, true); $table->foreign('theme_id', 'theme_setting_keys_to_theme')->references('id')->on('themes')->onDelete('cascade'); $table->string('key'); $table->timestamps(); }); Schema::create('themes_setting_key_translations', function (Blueprint $table) { $table->increments('id'); $table->integer('key_id', false, true); $table->foreign('key_id', 'translations_to_theme_setting_keys')->references('id')->on('themes_setting_keys')->onDelete('cascade'); $table->string('locale', 5); $table->string('name'); $table->string('explanation'); $table->timestamps(); }); }
/** * @param array $setting * @return mixed * @throws Exception */ protected function settingGetType(array $setting) { if (!static::$types) { static::$types = ThemeSettingType::all()->keyBy('name'); } if (!static::$types->has($setting['type'])) { throw new Exception('Invalid setting type provided'); } return static::$types->get($setting['type']); }