id . $name; if (Cache::has($fullName)) { Cache::forget($fullName); } Preference::where('user_id', Auth::user()->id)->where('name', $name)->delete(); return true; } /** * @param $name * @param null $default * * @return Configuration|null */ public function get($name, $default = null) { $fullName = 'ff-config-' . $name; if (Cache::has($fullName)) { return Cache::get($fullName); } $config = Configuration::where('name', $name)->first(['id', 'name', 'data']); if ($config) { Cache::forever($fullName, $config); return $config; } // no preference found and default is null: if (is_null($default)) { // return NULL return null; } return $this->set($name, $default); } /** * @param $name * @param string $value * * @return Configuration */ public function set($name, $value): Configuration { $item = $this->get($name, $value); $item->data = $value; $item->save(); Cache::forget('ff-config-' . $name); return $item; } }