Exemplo n.º 1
0
 /**
  * @param        $name
  * @param string $value
  *
  * @return Preference
  */
 public function set($name, $value)
 {
     $fullName = 'preference' . Auth::user()->id . $name;
     Cache::forget($fullName);
     $pref = Preference::where('user_id', Auth::user()->id)->where('name', $name)->first(['id', 'name', 'data_encrypted']);
     if ($pref) {
         $pref->data = $value;
     } else {
         $pref = new Preference();
         $pref->name = $name;
         $pref->data = $value;
         $pref->user()->associate(Auth::user());
     }
     $pref->save();
     Cache::forever($fullName, $pref);
     return $pref;
 }
Exemplo n.º 2
0
 protected function createPreferences()
 {
     $preference = new Preference();
     $preference->name = 'frontPageAccounts';
     $preference->data = [1];
     $preference->user()->associate($this->user);
     $preference->save();
 }
Exemplo n.º 3
0
 /**
  * @param \FireflyIII\User $user
  * @param                  $name
  * @param string           $value
  *
  * @return Preference
  */
 public function setForUser(User $user, $name, $value) : Preference
 {
     $fullName = 'preference' . $user->id . $name;
     Cache::forget($fullName);
     $pref = Preference::where('user_id', $user->id)->where('name', $name)->first(['id', 'name', 'data']);
     if (!is_null($pref)) {
         $pref->data = $value;
         $pref->save();
         Cache::forever($fullName, $pref);
         return $pref;
     }
     $pref = new Preference();
     $pref->name = $name;
     $pref->data = $value;
     $pref->user()->associate($user);
     $pref->save();
     Cache::forever($fullName, $pref);
     return $pref;
 }