public static function set($key, $value) { if (!empty($key)) { $appOption = self::$app_options->where('key', $key)->first(); if ($appOption) { $appOption->value = $value; $appOption->save(); } else { $appOption = new AppOption(); $appOption->key = $key; $appOption->value = $value; $appOption->save(); } return $appOption; } return false; }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy(Request $request, $key) { $option = AppOption::where('key', $key)->firstOrFail(); $redirect_url = adminUrl('app-options'); $rdr = $request->session()->pull(AppConfig::KEY_REDIRECT_URL, ''); if (!empty($rdr)) { $redirect_url = $rdr; } return $option->delete() === true ? redirect($redirect_url) : redirect($redirect_url)->withErrors([trans('error.database_delete')]); }