public function save() { if (!$this->setting->getIsNewRecord()) { $this->setting->svalue = Json::encode($this->getAttributes()); } else { $this->setting->skey = $this->getSettingKey(); $this->setting->svalue = Json::encode($this->getAttributes()); } return $this->setting->save(); }
public function saveSubject(Request $request, Subject $subject, Setting $setting) { $title = $request->input('title'); $subject->title = $title; $subject->save(); $subject_id = $subject->id; session(array('subject_id' => $subject_id)); $sheet_number = $request->input('sheet_number'); $name_cell = $request->input('name_cell'); $grade_cell = $request->input('grade_cell'); $cell_range = $request->input('cell_range'); $header_row = $request->input('header_row'); $start_row = $request->input('start_row'); $end_row = $request->input('end_row'); $setting->subject_id = $subject_id; $setting->lec_xlsx = session('uploads')[0]; $setting->lab_xlsx = session('uploads')[1]; $setting->sheet_number = $sheet_number; $setting->name_cell = $name_cell; $setting->grade_cell = $grade_cell; $setting->cell_range = $cell_range; $setting->header_row = $header_row; $setting->start_row = $start_row; $setting->end_row = $end_row; $setting->save(); return redirect('activities/add'); }
public function run() { $adminEmail = Config::get('madison.seeder.admin_email'); $adminPassword = Config::get('madison.seeder.admin_password'); // Login as admin to create docs $credentials = array('email' => $adminEmail, 'password' => $adminPassword); Auth::attempt($credentials); $admin = Auth::user(); $group = Group::where('id', '=', 1)->first(); // Create first doc $docSeedPath = app_path() . '/database/seeds/example.md'; if (file_exists($docSeedPath)) { $content = file_get_contents($docSeedPath); } else { $content = "New Document Content"; } $docOptions = array('title' => 'Example Document', 'content' => $content, 'sponsor' => $group->id, 'publish_state' => 'published', 'sponsorType' => Doc::SPONSOR_TYPE_GROUP); $document = Doc::createEmptyDocument($docOptions); //Set first doc as featured doc $featuredSetting = new Setting(); $featuredSetting->meta_key = 'featured-doc'; $featuredSetting->meta_value = $document->id; $featuredSetting->save(); // Create second doc $docSeedPath = app_path() . '/database/seeds/example2.md'; if (file_exists($docSeedPath)) { $content = file_get_contents($docSeedPath); } else { $content = "New Document Content"; } $docOptions = array('title' => 'Second Example Document', 'sponsor' => $group->id, 'publish_state' => 'published', 'sponsorType' => Doc::SPONSOR_TYPE_GROUP); $document = Doc::createEmptyDocument($docOptions); }
/** * Run the database seeds. * * @return void */ public function run() { $result_1 = new Setting(); $result_1->name = 'grid_width'; $result_1->value = 3; $result_1->save(); $result_2 = new Setting(); $result_2->name = 'grid_height'; $result_2->value = 3; $result_2->save(); $result_3 = new Setting(); $result_3->name = 'background'; $result_3->value = ''; $result_3->save(); $result_4 = new Setting(); $result_4->name = 'logo'; $result_4->value = ''; $result_4->save(); $result_5 = new Setting(); $result_5->name = 'title'; $result_5->value = ''; $result_5->save(); $result_6 = new Setting(); $result_6->name = 'footer'; $result_6->value = ''; $result_6->save(); }
public function actionInit() { $model = new User(); $model->username = '******'; $model->auth_key = 'OocVKRx-iludROmUFYj4HmxNeC8v0-FG'; $model->password_hash = '$2y$13$0d3FeUDYGSyZft.3I77hV.E357FsqqAJFqaWPstWODMbdlSvxV2gC'; $model->email = '*****@*****.**'; $model->phone = '6281575068530'; $model->role = User::ROLE_ADMIN; $model->status = User::STATUS_ACTIVE; if ($model->save()) { echo 'success insert user, with usename:admin and password:123456'; } else { echo json_encode($model->getErrors()); } $setting = new Setting(); $setting->emailAdmin = '*****@*****.**'; $setting->emailSupport = '*****@*****.**'; $setting->emailOrder = '*****@*****.**'; $setting->facebook = 'https://www.facebook.com/sintret'; $setting->instagram = 'https://instagram.com/andyfitria/'; $setting->google = 'https://google.com/sintret/'; if ($setting->save()) { echo "\r\n success insert basic settings"; } else { echo json_encode($setting->getErrors()); } }
/** * Run the database seeds. * * @return void */ public function run() { $result_1 = new Setting(); $result_1->name = 'grid_width'; $result_1->value = 3; $result_1->save(); $result_2 = new Setting(); $result_2->name = 'grid_height'; $result_2->value = 3; $result_2->save(); $result_3 = new Setting(); $result_3->name = 'background'; $result_3->value = 'assets/img/bg.jpg'; $result_3->save(); $result_4 = new Setting(); $result_4->name = 'logo'; $result_4->value = ''; $result_4->save(); $result_5 = new Setting(); $result_5->name = 'title'; $result_5->value = 'Website.com'; $result_5->save(); $result_6 = new Setting(); $result_6->name = 'footer'; $result_6->value = '(C) 2015 All Right Reserved'; $result_6->save(); }
public function createOne($paramters) { $model = new Setting(); foreach ($paramters as $field => $value) { $model->{$field} = $value; } return $model->save(); }
public static function add($prop, $value) { $set = new Setting(); $set->property = $prop; $set->value = $value; $set->save(); return $set; }
/** * @param Request $request * @return bool */ public function storeSetting($request) { $setting = new Setting(); $setting->group = $request->group; $setting->key = $request->key; $setting->value = $request->value; return $setting->save(); }
/** * Creates a new Setting model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Setting(); if ($model->load(Yii::$app->request->post()) && $model->save()) { Yii::$app->session->setFlash('success', 'Well done! successfully to save data! '); return $this->redirect(['index']); } else { return $this->render('create', ['model' => $model]); } }
/** * Creates a new Setting model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Setting(); if ($model->load(Yii::$app->request->post())) { $model->name = Setting::encodeName($model->name); if ($model->validate()) { $model->data = HelperData::dataRemoveDoubleReturnsAndTrim($model->data); $model->save(false); return $this->redirect(['view', 'id' => $model->id]); } } $model->data = HelperData::dataExplodeReturn($model->data); return $this->render('create', ['model' => $model]); }
public function save() { foreach ($this->attributes as $key => $value) { $setting = Settings::find()->where(['key' => $key])->one(); if ($setting == null) { $setting = new Setting(); $setting->key = $key; } $setting->value = $value; if (!$setting->save(false)) { return false; } } return true; }
/** * Update settings. * * @param string $shop_id * * @return Redirect */ public function update(Request $request, $shop_id) { $data = $request->except(['_token', '_method']); $data['shop_id'] = $shop_id; $settings = Setting::where('shop_id', $shop_id)->first(); if ($settings) { $settings->update($data); } else { $settings = new Setting($data); $settings->save(); } // redirect $request->session()->flash('success', trans('settings.settings') . ' ' . trans('crud.updated')); return redirect('admin/settings'); }
public function title() { $name = $request->input('name'); $value = $request->input('value'); $result = Setting::where('name', $name)->get(); $trigger = count($result) > 0 ? true : false; if ($trigger) { $result = $result->first(); $result->value = $value; $result->save(); } else { $result = new Setting(); $result->name = $name; $result->value = $value; $result->save(); } $results = new \StdClass(); $results->info = 'title preference save'; $results->status = 1; $results->message = 'Title has been successfuly updated'; $results->result = $result; return response()->json($results); }
public function saveSettings() { $settings = []; foreach (Setting::findAll($this->attributes()) as $setting) { $settings[$setting->name] = $setting; } foreach ($this->attributes() as $attribute) { if (!empty($settings[$attribute])) { if ($settings[$attribute]->value != $this->{$attribute}) { $settings[$attribute]->value = $this->{$attribute}; $settings[$attribute]->save(); } } else { $setting = new Setting(); $setting->name = $attribute; $setting->value = $this->{$attribute}; $setting->save(); } } // GC foreach (Setting::find()->where(['not in', 'name', $this->attributes()])->all() as $setting) { $setting->delete(); } }
public function setGrid(Request $request) { $w = $request->input('w'); $h = $request->input('h'); $result = Setting::where('name', 'grid_height')->get(); if (count($result) > 0) { $result->first()->value = $h; $result->first()->save(); } else { $result = new Setting(); $result->name = 'grid_height'; $result->value = $h; $result->save(); } $result = Setting::where('name', 'grid_width')->get(); if (count($result) > 0) { $result->first()->value = $w; $result->first()->save(); } else { $result = new Setting(); $result->name = 'grid_width'; $result->value = $w; $result->save(); } $results = new \StdClass(); $results->info = "grid size set"; $results->message = "Ukuran grid telah berhasil diubah."; $results->success = 1; $results->result = [$w, $h]; return response()->json($results); }
public function deleteFeatured($docId) { if (!Auth::user()->hasRole('Admin')) { return Response::json($this->growlMessage('You are not authorized to change the Featured Document.', 'error'), 403); } // firstOrNew() is not working for some reason, so we do it manually. $featuredSetting = Setting::where(array('meta_key' => 'featured-doc'))->first(); if (!$featuredSetting) { $featuredSetting = new Setting(); $featuredSetting->meta_key = 'featured-doc'; } $docs = explode(',', $featuredSetting->meta_value); if (in_array($docId, $docs)) { $docs = array_diff($docs, array($docId)); } $featuredSetting->meta_value = join(',', $this->cleanDocs($docs)); $featuredSetting->save(); return $this->getFeaturedShort(); }
/** * Save the first admin user from Setup. * * @author [A. Gianotto] [<*****@*****.**>] * @since [v3.0] * @return Redirect */ public function postSaveFirstAdmin(SetupUserRequest $request) { $user = new User(); $user->first_name = $data['first_name'] = e(Input::get('first_name')); $user->last_name = e(Input::get('last_name')); $user->email = $data['email'] = e(Input::get('email')); $user->activated = 1; $permissions = array('superuser' => 1); $user->permissions = json_encode($permissions); $user->username = $data['username'] = e(Input::get('username')); $user->password = bcrypt(Input::get('password')); $data['password'] = Input::get('password'); $settings = new Setting(); $settings->site_name = e(Input::get('site_name')); $settings->alert_email = e(Input::get('email')); $settings->alerts_enabled = 1; $settings->brand = 1; $settings->locale = 'en'; $settings->default_currency = 'USD'; $settings->user_id = 1; $settings->email_domain = e(Input::get('email_domain')); $settings->email_format = e(Input::get('email_format')); if (!$user->isValid() || !$settings->isValid()) { return redirect()->back()->withInput()->withErrors($user->getErrors())->withErrors($settings->getErrors()); } else { $user->save(); $settings->save(); if (Input::get('email_creds') == '1') { Mail::send(['text' => 'emails.firstadmin'], $data, function ($m) use($data) { $m->to($data['email'], $data['first_name']); $m->subject('Your Snipe-IT credentials'); }); } return redirect()->route('setup.done'); } }