Esempio n. 1
0
 public function onSwitch()
 {
     $id = post('user_id');
     $name = post('col');
     $value = !post($name);
     $profile = ProfileModel::where('user_id', $id)->get();
     //ensure that user always has a profile
     if (!$profile) {
         ProfileModel::getFromUser(UserModel::find($id));
         $profile = ProfileModel::where('user_id', $id)->get();
     }
     ProfileModel::where('user_id', $id)->update([$name => $value]);
     return ['value' => $value];
 }
Esempio n. 2
0
 private function extendUserFormFields($form, $model, $context)
 {
     if (!$model instanceof UserModel) {
         return;
     }
     if (!$model->exists) {
         return;
     }
     //ensure that user always has a profile
     ProfileModel::getFromUser($model);
     $configFile = __DIR__ . '/models/profile/fields.yaml';
     $config = Yaml::parse(File::get($configFile));
     $form->addTabFields($config);
 }