本文整理汇总了PHP中app\Setting::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Setting::save方法的具体用法?PHP Setting::save怎么用?PHP Setting::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Setting
的用法示例。
在下文中一共展示了Setting::save方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: patchSettings
/**
* Update the settings in storage.
*
* @param Setting $setting
* @param SettingRequest $request
* @return Response
*/
public function patchSettings(Setting $setting, SettingRequest $request)
{
$data = $this->storeImage($request, 'logo');
$setting->fill($data);
$setting->save() == true ? Flash::success(trans('admin.update.success')) : Flash::error(trans('admin.update.fail'));
return redirect(route('admin.setting.index'));
}
示例2: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store(Request $request)
{
//
$setting = new Setting();
$setting->serty_id = $request->serty_id;
$setting->sett_hour = $request->hour;
$setting->save();
return Redirect::to('setting');
}
示例3: saveSettings
public function saveSettings(Request $request)
{
$input = $request->all();
$notification = Setting::where('name', 'notification')->first();
if (!count($notification)) {
$notification = new Setting();
$notification->name = 'notification';
}
$notification->value = $input['notification'];
$notification->save();
return redirect()->route('admin');
}
示例4: addSetting
public static function addSetting($setting, $value)
{
$settingobj = Setting::where('name', '=', $setting)->first();
if ($settingobj) {
return;
}
$settingobj = new Setting();
if ($setting) {
$settingobj->name = $setting;
$settingobj->value = $value;
$settingobj->save();
}
}
示例5: index
public function index()
{
if (Request::isMethod('get')) {
$lang = Language::all();
$settings = Setting::all();
return view('admin.settings.index', array('langs' => $lang, 'settings' => $settings));
}
/// POST
$data = Request::all();
$s = new Setting();
$s->name = $data['name'];
$s->lang_code = $data['lang_code'];
$s->value = $data['value'];
$s->type = 'var';
$s->save();
return redirect('admin/settings');
}
示例6: update
public function update(Request $request, Setting $setting)
{
$insert = $setting->fill($request->input())->save();
$image = \Input::get('image');
if ($image != '') {
$imagename = 'setting-' . rand(11111, 99999) . '-gudperna.png';
$image = str_replace(' ', '+', $image);
list($type, $image) = explode(';', $image);
list(, $image) = explode(',', $image);
$image = base64_decode($image);
file_put_contents('upload/img/' . $imagename, $image);
$setting->image = $imagename;
$setting->save();
}
if ($insert) {
return 0;
} else {
return 1;
}
}
示例7: create
public function create()
{
// check if it's our form
if (Session::token() !== Input::get('_token')) {
return response()->json(array('msg' => 'Unauthorized attempt to create Setting'));
}
// retrieve the data
$setting_name = Input::get('setting_name');
$setting_value = Input::get('setting_value');
//..................
//validate data and store in db here...
$setting = new Setting();
$setting->setting_name = $setting_name;
$setting->setting_value = $setting_value;
$setting->save();
//..................
// create a response message and send it.
$response = array('status' => 'success', 'msg' => 'setting created successfully');
return response()->json($response);
}
示例8: upload
public function upload()
{
// getting all of the post data
$file = array('image' => Input::file('image'));
// setting up rules
$rules = array('image' => 'required');
//mimes:jpeg,bmp,png and for max size max:10000
// doing the validation, passing post data, rules and the messages
$validator = Validator::make($file, $rules);
Cache::flush();
if ($validator->fails()) {
// send back to the page with the input data and errors
return Redirect::to('logo')->withInput()->withErrors($validator);
} else {
// checking file is valid.
if (Input::file('image')->isValid()) {
$destinationPath = 'uploads';
// upload path
$extension = Input::file('image')->getClientOriginalExtension();
// getting image extension
$fileName = rand(11111, 99999) . '.' . $extension;
// renameing image
Input::file('image')->move($destinationPath, $fileName);
// uploading file to given path// sending back with message
//store into db
$logoUrl = Setting::where('meta_name', 'logo_url')->first();
if (empty($logoUrl)) {
$logoUrl = new Setting();
}
$logoUrl->meta_name = 'logoUrl';
$logoUrl->meta_value = $destinationPath . '/' . $fileName;
$logoUrl->save();
return redirect()->route('logo')->with('message', 'Logo updated.')->with('message-class', 'success');
} else {
// sending back with error message.
Session::flash('error', 'uploaded file is not valid');
return redirect()->route('logo')->with('message', 'Uploaded file is not valid.')->with('message-class', 'error');
}
}
}
示例9: update
public function update(Request $request)
{
$langs = get_langs();
foreach ($langs as $lang) {
$datas = $request->input($lang->code);
foreach ($datas as $key => $value) {
$value = is_array($value) ? serialize($value) : $value;
$args = ['lang_id' => $lang->id, 'key' => $key, 'value' => $value];
$cond = Setting::where('key', $key)->where('lang_id', $lang->id);
if ($cond->count() > 0) {
$cond->update(['value' => $value]);
} else {
$meta = new Setting();
$meta->lang_id = $lang->id;
$meta->key = $key;
$meta->value = $value;
$meta->save();
}
}
}
return redirect()->back()->with('Mess', 'Cập nhật thành công');
}
示例10: store
public function store(Request $request)
{
$this->validate($request, ['app_name' => 'required|max:100']);
\DB::beginTransaction();
try {
$settings = Setting::find(1);
if (!empty($settings)) {
$settings->app_name = $request->app_name;
$settings->update();
} else {
$settings = new Setting();
$settings->app_name = $request->app_name;
$settings->save();
}
\DB::commit();
Session::flash('flash_message', 'Settings successfully updated!');
return redirect()->back();
} catch (Exception $e) {
DB::rollBack();
return redirect()->back();
}
}
示例11: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('settings')->truncate();
$setting = new Setting();
$setting->name = "adult_rate_day";
$setting->value = 175;
$setting->save();
$setting = new Setting();
$setting->name = "adult_rate_night";
$setting->value = 195;
$setting->save();
$setting = new Setting();
$setting->name = "kids_rate_day";
$setting->value = 135;
$setting->save();
$setting = new Setting();
$setting->name = "kids_rate_night";
$setting->value = 155;
$setting->save();
$setting = new Setting();
$setting->name = "toddlers";
$setting->value = 100;
$setting->save();
}
示例12: set
/**
* Set
* @param $key
* @param $value
*
* @return Setting|void
*/
public function set($key, $value)
{
if ($this->get('installed') && !Auth::user()->isAdmin) {
abort(403);
}
if (in_array($key, $this->envSettings)) {
return $this->writeToEnvFile($key, $value);
}
$setting = Setting::where('name', $key)->first();
if (!$setting) {
$setting = new Setting(['name' => $key]);
}
$setting->value = $value;
$setting->save();
return $setting;
}
示例13: settingsSave
public function settingsSave(Request $request)
{
$s = Setting::first();
if (!$s) {
$s = new Setting();
}
$s->fill($request->all());
$s->save();
return redirect('/dashboard/settings');
}
示例14: patchSettings
/**
* Update the settings in storage.
*
* @param Setting $setting
* @param SettingRequest $request
* @return Response
*/
public function patchSettings(Setting $setting, SettingRequest $request)
{
$setting->fill(ImageService::uploadImage($request, 'logo'));
$setting->save() ? Flash::success(trans('admin.update.success')) : Flash::error(trans('admin.update.fail'));
return redirect(route('admin.setting.index'));
}