コード例 #1
0
ファイル: SettingsForm.php プロジェクト: Junyue/zidisha2
 public function getRules($data)
 {
     $rules = [];
     $groups = Setting::getGroups();
     foreach ($groups as $group => $groupSettings) {
         foreach ($groupSettings as $name => $options) {
             if (is_array($options['rule'])) {
                 $rule = array_merge(['required'], $options['rule']);
             } else {
                 $rule = 'required|' . $options['rule'];
             }
             $rules[str_replace('.', '_', $name)] = $rule;
         }
     }
     return $rules;
 }
コード例 #2
0
ファイル: Setting.php プロジェクト: Junyue/zidisha2
 public static function import($defaults = [])
 {
     static::$nameToValue = [];
     $groups = Setting::getGroups();
     $settings = SettingQuery::create()->find();
     $nameToValue = $settings->toKeyValue('name', 'value');
     foreach ($groups as $group => $groupSettings) {
         foreach ($groupSettings as $name => $options) {
             if (!isset($nameToValue[$name])) {
                 $setting = new Setting();
                 $setting->setName($name)->setValue(array_get($defaults, $name, $options['default']));
                 $setting->save();
             }
         }
     }
 }
コード例 #3
0
ファイル: AdminController.php プロジェクト: Junyue/zidisha2
 public function getSettings()
 {
     $settingsForm = new SettingsForm();
     $groups = Setting::getGroups();
     return View::make('admin.settings', compact('settingsForm', 'groups'));
 }