本文整理汇总了PHP中app\models\Setting::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Setting::save方法的具体用法?PHP Setting::save怎么用?PHP Setting::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Setting
的用法示例。
在下文中一共展示了Setting::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
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();
}
示例2: saveSubject
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');
}
示例3: run
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);
}
示例4: run
/**
* 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();
}
示例5: actionInit
public function actionInit()
{
$model = new User();
$model->username = 'admin';
$model->auth_key = 'OocVKRx-iludROmUFYj4HmxNeC8v0-FG';
$model->password_hash = '$2y$13$0d3FeUDYGSyZft.3I77hV.E357FsqqAJFqaWPstWODMbdlSvxV2gC';
$model->email = 'sintret@gmail.com';
$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 = 'sintret@gmail.com';
$setting->emailSupport = 'sintret@gmail.com';
$setting->emailOrder = 'sintret@gmail.com';
$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());
}
}
示例6: run
/**
* 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();
}
示例7: createOne
public function createOne($paramters)
{
$model = new Setting();
foreach ($paramters as $field => $value) {
$model->{$field} = $value;
}
return $model->save();
}
示例8: add
public static function add($prop, $value)
{
$set = new Setting();
$set->property = $prop;
$set->value = $value;
$set->save();
return $set;
}
示例9: storeSetting
/**
* @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();
}
示例10: actionCreate
/**
* 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]);
}
}
示例11: actionCreate
/**
* 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]);
}
示例12: save
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;
}
示例13: update
/**
* 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');
}
示例14: title
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);
}
示例15: saveSettings
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();
}
}