本文整理汇总了PHP中app\models\Setting类的典型用法代码示例。如果您正苦于以下问题:PHP Setting类的具体用法?PHP Setting怎么用?PHP Setting使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Setting类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例2: 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();
}
示例3: 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());
}
}
示例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 = '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();
}
示例5: actionIndex
public function actionIndex()
{
$setting = new Setting();
$data['siteName'] = $setting->getSiteName()->value;
$data['address'] = $setting->getAddress()->value;
$data['nickName'] = $setting->getNickName()->value;
$data['desc'] = $setting->getDesc()->value;
return $this->render('index', ['info' => $data]);
}
示例6: 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();
}
示例7: 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;
}
示例8: 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');
}
示例9: actionSetmail
public function actionSetmail()
{
$model = new Setting();
$message = true;
$query = Setting::find()->one();
if (Yii::$app->request->post()) {
$request = Yii::$app->request;
$password = $request->post('Setting')['password'];
$username = $request->post('Setting')['username'];
$sendhost = $request->post('Setting')['sendhost'];
$sendport = $request->post('Setting')['sendport'];
$user = $request->post('Setting')['user'];
$receivehost = $request->post('Setting')['receivehost'];
$receiveport = $request->post('Setting')['receiveport'];
$model1 = new Receive();
$obj = new receiveMail($user, $password, $username, $receivehost, 'imap', '993', 'ture');
if ($obj->connect()) {
$query = Setting::find()->one();
$query->sendhost = $sendhost;
$query->sendport = $sendport;
$query->user = $user;
$query->password = $password;
$query->username = $username;
$query->receivehost = $receivehost;
$query->receiveport = $receiveport;
$query->save();
return $this->render('setting', ['model' => $model, 'settingMessage' => $query, 'message' => $message]);
} else {
$message = false;
return $this->render('setting', ['model' => $model, 'settingMessage' => $query, 'message' => $message]);
}
} else {
return $this->render('setting', ['model' => $model, 'settingMessage' => $query, 'message' => $message]);
}
}
示例10: sync
/**
* Sync the media. Oh sync the media.
*
* @param string|null $path
* @param array $tags The tags to sync.
* Only taken into account for existing records.
* New records will have all tags synced in regardless.
* @param bool $force Whether to force syncing even unchanged files
* @param SyncMedia $syncCommand The SyncMedia command object, to log to console if executed by artisan.
*/
public function sync($path = null, $tags = [], $force = false, SyncMedia $syncCommand = null)
{
if (!app()->runningInConsole()) {
set_time_limit(env('APP_MAX_SCAN_TIME', 600));
}
$path = $path ?: Setting::get('media_path');
$this->setTags($tags);
$results = ['good' => [], 'bad' => [], 'ugly' => []];
$getID3 = new getID3();
foreach ($this->gatherFiles($path) as $file) {
$file = new File($file, $getID3);
$song = $file->sync($this->tags, $force);
if ($song === true) {
$results['ugly'][] = $file;
} elseif ($song === false) {
$results['bad'][] = $file;
} else {
$results['good'][] = $file;
}
if ($syncCommand) {
$syncCommand->logToConsole($file->getPath(), $song);
}
}
// Delete non-existing songs.
$hashes = array_map(function ($f) {
return self::getHash($f->getPath());
}, array_merge($results['ugly'], $results['good']));
Song::whereNotIn('id', $hashes)->delete();
// Trigger LibraryChanged, so that TidyLibrary handler is fired to, erm, tidy our library.
event(new LibraryChanged());
}
示例11: actionSendChat
public function actionSendChat()
{
if (!empty($_POST)) {
echo \sintret\chat\ChatRoom::sendChat($_POST);
$message = Yii::$app->user->identity->username . ' : ' . $_POST['message'];
$pos = strpos($message, "@");
$setting = \app\models\Setting::findOne(1);
if ($pos !== FALSE) {
// $w = new WhatsApp($number, $app, $password);
$usernameSendgrid = $setting->sendgridUsername;
$passwordSendgrid = $setting->sendgridPassword;
$users = \app\models\User::find()->where(['status' => \app\models\User::STATUS_ACTIVE])->all();
foreach ($users as $model) {
$aprot = '@' . strtolower($model->username);
if (strpos($message, $aprot) !== false) {
$sendgrid = new \SendGrid($usernameSendgrid, $passwordSendgrid, array("turn_off_ssl_verification" => true));
$email = new \SendGrid\Email();
$email->addTo($model->email)->setFrom($setting->emailSupport)->setSubject('Chat from ' . $setting->applicationName)->setHtml($message);
$sendgrid->send($email);
} else {
}
}
}
}
}
示例12: stream
/**
* Stream the current song using nginx's X-Accel-Redirect.
*/
public function stream()
{
header('X-Accel-Redirect: ' . str_replace(Setting::get('media_path'), '/media/', $this->song->path));
header("Content-Type: {$this->contentType}");
header('Content-Disposition: inline; filename="' . basename($this->song->path) . '"');
exit;
}
示例13: home
protected function home()
{
$bigevent = [];
$settings = Setting::all();
foreach ($settings as $setting) {
$arr = ['name' => $setting['name'], 'value' => $setting['value']];
if (substr($setting['key'], 0, 3) === "be-") {
$bigevent[$setting['key']] = $arr;
} else {
$other[$setting['key']] = $arr;
}
}
//BEAUCOUPS D'APPELS A LA BDD, CERTES EN HAUT C'EST PAS FORCEMENT MIEUX, de tout facon faudra faire un systeme de "event mis en avant" en faisant les events.
/*
$about = Setting::where('key', 'about')->first();
$bigevent["main-photo"] = Setting::where('key', 'be-main-photo')->first()->value;
$bigevent["bg-photo"] = Setting::where('key', 'be-bg-photo')->first()->value;
$bigevent["title"] = Setting::where('key', 'be-title')->first()->value;
$bigevent["label"] = Setting::where('key', 'be-label')->first()->value;
$bigevent["description"] = Setting::where('key', 'be-description')->first()->value;
$bigevent["link"] = Setting::where('key', 'be-link')->first()->value;
$agenda = Setting::where('key', 'agenda')->first()->value;
$posts = ClubPost::all();
return view('home')->with([
'about' => $about->value,
'posts' => $posts,
'bigevent' => $bigevent,
'agenda' => $agenda]);
*/
$posts = ClubPost::all();
return view('home')->with(['posts' => $posts, 'bigevent' => $bigevent, 'other' => $other]);
}
示例14: __construct
/**
* Display a listing of the resource.
*
* @return Response
*/
public function __construct()
{
$setting = Models\Setting::first();
$this->data['menu'] = Models\Menu::with('child')->where('level', 0)->get();
$this->data['berita'] = Models\Berita::orderBy('id_berita', 'desc')->limit(6)->get();
$this->data['pengumuman'] = Models\Pengumuman::orderBy('tanggal', 'desc')->limit(10)->get();
$this->data['agenda'] = Models\Agenda::orderBy('tgl_posting', 'desc')->limit(5)->get();
$this->data['polling'] = Models\Polling::with('jawaban')->where('status', 'Y')->limit(1)->first();
$this->data['title'] = $setting->title_web;
$this->data['desc'] = $setting->desc_web;
$this->data['key'] = $setting->key_web;
$this->data['logo'] = $setting->logo;
$this->data['header_img'] = $setting->bg_header;
$this->data['icon'] = $setting->favicon;
$this->data['facebook'] = $setting->facebook;
$this->data['peta_latitude'] = $setting->peta_latitude;
$this->data['peta_longitude'] = $setting->peta_longitude;
$this->data['twitter'] = $setting->twitter;
$this->data['gplus'] = $setting->gplus;
$this->data['slider_home'] = Models\Berita::orderBy('tanggal', 'desc')->limit(5)->get();
$this->data['galeri_home'] = Models\Foto::OrderBy('id_foto', 'desc')->paginate(9);
$this->data['opini_home'] = Models\Berita::where('kategori_berita', 5)->orderBy('id_berita', 'desc')->limit(6)->get();
$this->data['banner'] = Models\Banner::where('id', 1)->first();
$this->data['link'] = Models\Link::orderBy('id', 'desc')->limit(5)->get();
$this->data['publikasi'] = Models\Publikasi::orderBy('id', 'desc')->limit(3)->get();
$this->data['setting'] = $setting;
}
示例15: init
public function init()
{
// actions
// translate
foreach ($this->actions as $actions => $name) {
$this->actions[$actions] = Yii::t('app', $name);
}
// actions values
$this->actions_values['taskdefined'] = TaskDefined::getAllIdName();
$this->actions_values['setting'] = Setting::getAllIdName();
$this->actions_values['rule'] = Rule::getAllIdName();
$this->actions_values['rulevalue'] = RuleValue::getAllIdName();
$this->actions_values['ruleextra'] = RuleExtra::getAllIdName();
$this->actions_values['ruledate'] = RuleDate::getAllIdName();
// values
// translate
foreach ($this->values as $values => $name) {
$this->values[$values] = Yii::t('app', $name);
}
// values_values
$this->values_values['taskdefined'] = TaskDefined::getAllIdName();
$this->values_values['setting'] = Setting::getAllIdName();
$this->values_values['rule'] = Rule::getAllIdName();
$this->values_values['rulevalue'] = RuleValue::getAllIdName();
$this->values_values['ruleextra'] = RuleExtra::getAllIdName();
$this->values_values['ruledate'] = RuleDate::getAllIdName();
//$this->values = array_merge($modelRule->values, $modelRule->actions);
//$this->values_values = $modelRule->values;
// create weights from 0 to 5
for ($weight = 0; $weight <= 4; $weight++) {
$this->weights[$weight] = $weight;
}
parent::init();
}