/** * returns the value of $name setting as stored in DB // TODO refactor */ function setting($name, $default = false) { $setting = \App\Setting::where('name', $name)->first(); if ($setting) { return $setting->value; } return $default; }
/** * Static method to get a value from the settings table */ public static function get($key, $default = false) { $setting = \App\Setting::where('name', $key)->first(); if ($setting) { return $setting->value; } return $default; }
public function edit($locationID) { if (!Auth::check() || !Auth::user()->is_admin) { return response(view('errors.403', ['error' => $this->errorMessages['incorrect_permissions_news']]), 403); } $item = Location::find($locationID); // If no featured image, put in our default image $item->featured_image = $item->featured_image == '' ? Setting::where('name', 'default_profile_picture')->first()->setting : $item->featured_image; return view('locations.edit')->with('item', $item); }
/** * Update the specified resource in storage. * * @return Response */ public function update(GeneralRequest $request) { Setting::where('name', 'title')->update(['value' => $request->input('title')]); Setting::where('name', 'subtitle')->update(['value' => $request->input('subtitle')]); Setting::where('name', 'keywords')->update(['value' => $request->input('keywords')]); Setting::where('name', 'description')->update(['value' => $request->input('description')]); Setting::where('name', 'paginate_size')->update(['value' => $request->input('paginate_size')]); event(new SettingsChangedEvent()); flash()->success(trans('flash_messages.settings_general_success')); return redirect('admin/settings/general'); }
/** * Execute the job. * * @return void */ public function handle() { $data['user'] = $this->user; $data['event'] = $this->event; $data['ticket'] = $this->ticket; $data['company_logo'] = Setting::where('name', 'company_logo')->first()->setting; $data['company_name'] = Setting::where('name', 'company_name')->first()->setting; Mail::send('emails.ticket', $data, function ($message) use($data) { $message->from("no-reply@" . str_replace('http://', '', \URL::to('/')), $data['company_name']); $message->to($data['user']->email); }); }
public function update(SettingsUpdateRequest $request) { $configs = $request->all(); unset($configs["_method"]); unset($configs["_token"]); foreach ($configs as $name => $value) { $setting = Setting::where("name", $name)->first(); $setting->value = $value; $setting->save(); } return redirect()->route("admin.settings")->with("success", trans("realestateadmin::settings.updated")); }
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'); }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { $chart = Chart::find($id); if ($chart) { $data = new \StdClass(); $logoUrl = Setting::where('meta_name', 'logoUrl')->first(); $data->logoUrl = !empty($logoUrl) ? url('/') . '/' . $logoUrl->meta_value : ''; return view('view.show', compact('chart', 'data')); } else { return 'No chart found to view'; } }
protected function updateForFile($request, $name) { if ($request->hasfile($name)) { $file = $request->file($name); if (!$file->isValid()) { throw new Exception(trans('strings.image_not_invalid')); } $filename = $name . '.' . $file->getClientOriginalExtension(); $file->move(public_path('images/profile'), $filename); Setting::where('name', $name)->update(['value' => 'images/profile/' . $filename]); } }
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(); } }
/** * Show the application dashboard. * * @return Response */ public function index() { try { $isInstalled = Setting::where('name', 'is_installed')->firstOrFail(); } catch (ModelNotFoundException $e) { $isInstalled = Setting::create(['name' => 'is_installed', 'setting' => 'no']); } if ($isInstalled->setting != 'yes') { return Redirect::route('install'); } $data = ["event" => Event::first(), "upcomingEvents" => Event::take(3)->get(), "news" => News::take(6)->get(), "media" => Media::where('processed', true)->orderBy('id', 'DESC')->take(12)->get()]; return view('home')->with($data); }
/** * Display a listing of the resource. * * @return Response */ public function index() { $datasets = Dataset::all(); $datasources = Datasource::all(); $variables = Variable::all(); $categories = DatasetCategory::all(); $subcategories = DatasetSubcategory::all(); $varTypes = VariableType::all(); $sourceTemplate = Setting::where('meta_name', 'sourceTemplate')->first(); $data = ['datasets' => $datasets, 'datasources' => $datasources, 'variables' => $variables, 'categories' => $categories, 'subcategories' => $subcategories, 'varTypes' => $varTypes, 'sourceTemplate' => $sourceTemplate]; $response = view('import.index')->with('data', $data); return $response; }
public function index() { if (!Auth::guest() && (Auth::user()->isAdmin() || Auth::user()->isActive())) { $notification = Setting::where('name', 'notification')->first(); if (!count($notification)) { $notification = ''; } else { $notification = $notification->value; } } else { $notification = ''; } return view('home')->with(['notification' => $notification]); }
/** * Recursively copy all the files from source folder to destination */ public static function recursive_copy($src, $dst) { $dir = opendir($src); @mkdir($dst); while (false !== ($file = readdir($dir))) { if ($file != '.' && $file != '..') { if (is_dir($src . '/' . $file)) { FileController::recursive_copy($src . '/' . $file, $dst . '/' . $file); } else { copy($src . '/' . $file, $dst . '/' . $file); } @chmod($dst . '/' . $file, 0775); @chgrp($dst . '/' . $file, Setting::where('name', 'REGISTRATION_GROUP')->first()->setting); } } closedir($dir); }
public function doUpdateSettings(Request $request) { $ids = []; foreach ($request->except('_token') as $key => $field) { $tmp = explode("-", $key); $setting_id = $tmp[1]; $ids[] = $setting_id; $setting = Setting::findOrFail($setting_id); $setting->updateValue($field); } if (Setting::where('type', 'checkbox')->count() > 0) { foreach (Setting::where('type', 'checkbox')->get() as $setting) { if (!in_array($setting->id, $ids)) { $setting->updateValue(0); } } } return redirect()->back()->with('settings-saved', true); }
function getUnsafewords($search) { $search_text = strtolower($search); $settings = Setting::where('id', '47')->first(); $settingsArr = $settings->toArray(); $settingsArrN = strtolower($settingsArr['config_value']); $settingPArr = explode(PHP_EOL, $settingsArrN); //dd($settingPArr); $exists = NULL; for ($i = 0; $i < count($settingPArr); $i++) { if ($exists == 0) { if (strpos($search_text, $settingPArr[$i]) !== false) { $exists = 1; } else { $exists = 0; } } } return $exists; }
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'); } } }
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'); }
private function getLDAPDefaults() { $setting_ids = ['registration_group', 'registration_group_id', 'default_home_directory', 'default_shell']; $settings = []; foreach ($setting_ids as $id) { $settings[$id] = Setting::where('name', $id)->first()->setting; } return $settings; }
/** * 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; }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit(Chart $chart, Request $request) { $config = json_decode($chart->config); if ($request->ajax()) { return response()->json($config); } else { $data = new \StdClass(); $data->variables = Variable::with('Dataset')->get(); $data->categories = DatasetCategory::all(); $data->subcategories = DatasetSubcategory::all(); $data->chartTypes = ChartType::lists('name', 'id'); $logoUrl = Setting::where('meta_name', 'logoUrl')->first(); $data->logoUrl = !empty($logoUrl) ? url('/') . '/' . $logoUrl->meta_value : ''; return view('charts.edit', compact('chart'))->with('data', $data); } }
/** * Execute the job. * * @return void */ public function handle() { if ($this->isSeeding) { $toTake = 200; // 200 societies $delay = 0; // Immediately } else { $toTake = 20; // 20 societies $delay = 600; // 10 Minutes } FacebookSession::setDefaultApplication(getenv('FB_ID'), getenv('FB_SECRET')); $session = FacebookSession::newAppSession(); try { $session->validate(); } catch (FacebookRequestException $ex) { // Session not valid, Graph API returned an exception with the reason. dd($ex); } catch (\Exception $ex) { // Graph API returned info, but it may mismatch the current app or have expired. dd($ex); } $store = \App\Setting::where('name', 'next_society')->first(); $lastUpdated = $store->setting; // Get last society ID updated; $societies = \App\Society::where('id', '>', $lastUpdated)->take($toTake)->orderBy('id')->get(); // Get Societies to query foreach ($societies as $society) { $request = new FacebookRequest($session, 'GET', '/' . $society->facebook_ref . '/events' . '?since=' . time() . '&fields=name,start_time,location,description,cover'); try { $response = $request->execute(); } catch (\Exception $ex) { continue; // TODO: Report errors back to us :) } $graphObject = $response->getGraphObject(); $events = $graphObject->asArray(); if (array_key_exists('data', $events)) { $events = $events['data']; foreach ($events as $fbEvent) { $storedEvent = \App\Event::firstOrNew(['facebook_id' => $fbEvent->id]); $storedEvent->society_id = $society->id; $storedEvent->title = $fbEvent->name; $storedEvent->time = $fbEvent->start_time; if (array_key_exists("description", $fbEvent)) { $storedEvent->description = $fbEvent->description; } if (array_key_exists("location", $fbEvent)) { $storedEvent->location = $fbEvent->location; } if (array_key_exists("cover", $fbEvent)) { $storedEvent->image = $fbEvent->cover->source; } $storedEvent->save(); } } } if (count($societies) < $toTake) { $store->setting = 0; } else { $store->setting += $toTake; } $store->save(); $job = (new \App\Jobs\UpdateEvents())->delay($delay); if (!$this->isSeeding) { $this->dispatch($job); } }
public function index() { $exportExcel = Request::input('exportExcel'); $lang = Request::input('lang'); $status = Request::input('status'); $period = Request::input('period'); $period_to = Request::input('period_to'); $data = array(); $data['langs'] = Language::all(); $users = User::where('role', '<>', 1)->get(array('id', 'name', 'cpr', 'account_number')); $list_user_assigns = array(); $list_users_lang = array(); /// filter by langs if ($lang && $lang == 'all' || !$lang) { foreach ($users as $k => $u) { $num = UserBlog::where('user_id', $u->id)->first(); if ($num) { $list_users_lang[$k] = $u; $list_users_lang[$k]['star'] = $num->star; $list_users_lang[$k]['lang_code'] = $num->lang_code; $star_value = Setting::where('lang_code', $num->lang_code)->where('name', 'star_value')->first()->value; if (!$star_value) { $star_value = Setting::where('lang_code', 'en')->where('name', 'star_value')->first()->value; } $list_users_lang[$k]['star_value'] = $star_value; $list_users_lang[$k]['total_amount'] = 0; } } } elseif ($lang && $lang != 'all') { foreach ($users as $k => $u) { $num = UserBlog::where('user_id', $u->id)->where('lang_code', $lang)->first(); if ($num) { $list_users_lang[$k] = $u; $list_users_lang[$k]['star'] = $num->star; $list_users_lang[$k]['lang_code'] = $num->lang_code; $star_value = Setting::where('lang_code', $num->lang_code)->where('name', 'star_value')->first()->value; if (!$star_value) { $star_value = Setting::where('lang_code', 'en')->where('name', 'star_value')->first()->value; } $list_users_lang[$k]['star_value'] = $star_value; $list_users_lang[$k]['total_amount'] = 0; } } } /// filter by status /// if status == all or dont isset status if ($status && $status == 'all' || !$status) { foreach ($list_users_lang as $k_u_l => $v_u_l) { /// if period = null, dont query by date if ($period == '' || !$period) { $ua = UserAssignment::where('user_id', $v_u_l->id)->whereIn('status', array(3, 5))->get(array('id', 'link', 'status', 'extra_star', 'approved_at', 'created_at')); } else { // if isset period and period != null $period = date('Y-m-d 00:00:00', strtotime($period)); $period_to = date('Y-m-d 23:59:59', strtotime($period_to)); $ua = UserAssignment::where('user_id', $v_u_l->id)->whereIn('status', array(3, 5))->where('approved_at', '>=', $period)->where('approved_at', '<=', $period_to)->get(array('id', 'link', 'status', 'extra_star', 'approved_at', 'created_at')); } if (count($ua)) { $list_user_assigns[$k_u_l] = $v_u_l; $list_user_assigns[$k_u_l]['user_assignment'] = $ua; foreach ($ua as $key_ua => $value_ua) { $list_user_assigns[$k_u_l]['user_assignment'][$key_ua]['amount'] = ($value_ua['extra_star'] + $v_u_l['star']) * $v_u_l['star_value']; $list_users_lang[$k_u_l]['total_amount'] += $list_user_assigns[$k_u_l]['user_assignment'][$key_ua]['amount']; } } } } elseif ($status && $status != 'all') { foreach ($list_users_lang as $k_u_l => $v_u_l) { if ($period == '' || !$period) { $ua = UserAssignment::where('user_id', $v_u_l->id)->where('status', $status)->get(array('id', 'link', 'status', 'extra_star', 'approved_at', 'created_at')); } else { $period = date('Y-m-d 00:00:00', strtotime($period)); $period_to = date('Y-m-d 23:59:59', strtotime($period_to)); $ua = UserAssignment::where('user_id', $v_u_l->id)->where('status', $status)->where('approved_at', '>=', $period)->where('approved_at', '<=', $period_to)->get(array('id', 'link', 'status', 'extra_star', 'approved_at', 'created_at')); } if (count($ua)) { $list_user_assigns[$k_u_l] = $v_u_l; $list_user_assigns[$k_u_l]['user_assignment'] = $ua; foreach ($ua as $key_ua => $value_ua) { $list_user_assigns[$k_u_l]['user_assignment'][$key_ua]['amount'] = ($value_ua['extra_star'] + $v_u_l['star']) * $v_u_l['star_value']; $list_users_lang[$k_u_l]['total_amount'] += $list_user_assigns[$k_u_l]['user_assignment'][$key_ua]['amount']; } } } } /// export excel if ($exportExcel) { return $this->exportExcel($list_user_assigns); } return view('admin.payment-list.index', array('users' => $list_user_assigns, 'langs' => $data['langs'])); }
public static function sendEmail() { $lowerBound = Setting::where('name', 'email_period_lower_bound')->first()->setting; $upperBound = Setting::where('name', 'email_period_upper_bound')->first()->setting; $currentHour = (int) date('H'); $email = Setting::where('name', 'email')->first()->setting; $name = Setting::where('name', 'name')->first()->setting; $lastEmail = Setting::where('name', 'last_email')->first(); $lastEmail->setting = time(); $lastEmail->save(); $lastNumber = Depression::orderBy('created_at', "DESC")->first()->id; // Encrypt yes and no so people can't accidentally trigger a choice $yes = Crypt::encrypt("yes"); $no = Crypt::encrypt("no"); if ($currentHour <= $lowerBound && $currentHour >= $upperBound) { // Do not send emails unless they're outside the set bounds $baseUrl = URL::to('/'); Mail::send('emails.reminder', ["yes" => $yes, "no" => $no, 'baseUrl' => $baseUrl], function ($m) use($email, $name, $lastNumber) { $m->from(env('MAIL_FROM_ADDRESS'), env('MAIL_FROM_NAME')); $m->to($email, $name)->subject('Are You Depressed? (' . ($lastNumber + 1) . ')'); }); } }
/** * Handles updating subscriptions * @return REDIRECT subscriptions */ public function updateSubscriptions() { $data = Request::only(['allSubscriptions']); // Trim and replace all extranneous whitespace then explode the array $data = explode(' ', trim(preg_replace('/\\s+/', ' ', $data['allSubscriptions']))); foreach ($data as $societyID) { if (1 <= $societyID && $societyID <= Setting::where('name', 'number_of_societies')->first()->setting) { try { // If subscription exists, cancel it $currentSubscription = Subscription::where('user_id', Auth::user()->id)->where('society_id', $societyID)->firstOrFail(); $currentSubscription->delete(); } catch (ModelNotFoundException $e) { // If subscription doesn't exist, create one Subscription::create(['society_id' => $societyID, 'user_id' => Auth::user()->id]); } } } return Redirect::route('subscriptions'); }
/** * Handle a settings request to the application. */ public function postShow(Request $request, $formKey) { if ($request->input('submit') && in_array($request->input('submit'), $this->validSettingsFormKey)) { $input = $request->all(); foreach ($input as $key => $val) { if (in_array($key, $this->exceptKey)) { continue; } else { $setting = Setting::where('config_key', '=', $key)->first(); $setting->config_value = $request->input($key); $setting->save(); } } $request->session()->flash('alert-success', 'Settings value has been saved successfully'); return redirect()->back()->withInput(); } else { $request->session()->flash('alert-danger', 'Invalid form name or post request !'); return redirect()->back()->withInput(); } }
public function ajax_get_setting_variable_by_customer_language() { $lang_code = Request::input('country_iso'); return Setting::where('type', 'var')->get(); }
public function edit() { $sourceTemplate = Setting::where('meta_name', 'sourceTemplate')->first(); return view('sourceTemplate.edit', compact('sourceTemplate')); }
public static function getOptions($name) { if (Setting::where('name', $name)->count() > 0) { $setting = Setting::where('name', $name)->first(); if ($setting->type == 'select_dynamic') { $options = new Collection(); switch ($name) { case 'manage_devices': $option = new SettingOption(); $option->id = 0; $option->value = 0; $option->label = 'Manage Devices'; $options->push($option); $option = new SettingOption(); $option->id = 1; $option->value = 'Device 1'; $option->label = 'Device 1'; $options->push($option); $option = new SettingOption(); $option->id = 2; $option->value = 'Device 2'; $option->label = 'Device 2'; $options->push($option); break; case 'recent_activity': $option = new SettingOption(); $option->id = 0; $option->value = 'Fake Activity 1'; $option->label = 'Fake Activity 1'; $options->push($option); $option = new SettingOption(); $option->id = 1; $option->value = 'Fake Activity 2'; $option->label = 'Fake Activity 2'; $options->push($option); $option = new SettingOption(); $option->id = 2; $option->value = 'Fake Activity 3'; $option->label = 'Fake Activity 3'; $options->push($option); break; default: $option = new SettingOption(); $option->id = 0; $option->value = 0; $option->label = 'No options set up'; $options->push($option); break; } return $options; } elseif ($setting->type == 'select' || $setting->type == 'radio') { $setting_option_query = SettingOption::where('setting_id', $setting->id)->orderBy('order_by', 'asc'); $options = new Collection(); if ($setting_option_query->count() > 0) { $options = $setting_option_query->get(); } else { $option = new SettingOption(); $option->value = 0; $option->label = 'No options set up'; $options->push($option); } return $options; } else { return false; } } else { return false; } }
public function showChart(Chart $chart) { $referer_s = \Request::header('referer'); if ($referer_s) { $root = parse_url(\Request::root()); $referer = parse_url($referer_s); if ($root['host'] == $referer['host'] && strlen($referer['path']) > 1 && !str_contains($referer_s, ".html") && !str_contains($referer_s, "wp-admin") && !str_contains($referer_s, "preview=true") && !str_contains($referer_s, "how-to") && !str_contains($referer_s, "grapher") && !str_contains($referer_s, "about") && !str_contains($referer_s, "roser/")) { $chart->origin_url = "https://" . $root['host'] . $referer['path']; $chart->save(); } } if ($chart) { $config = Chart::getConfigWithUrl($chart); $data = new \StdClass(); $logoUrl = Setting::where('meta_name', 'logoUrl')->first(); $data->logoUrl = !empty($logoUrl) ? url('/') . '/' . $logoUrl->meta_value : ''; $canonicalUrl = URL::to($chart->slug); // Make metadata for twitter embed cards! $chartMeta = new \StdClass(); // Replace the chart title placeholders with generic equivalents for now $title = $config->{"chart-name"}; $title = preg_replace("/, \\*time\\*/", " over time", $title); $title = preg_replace("/\\*time\\*/", "over time", $title); $chartMeta->title = $title; // Description is required by twitter if (isset($config->{"chart-subname"})) { $chartMeta->description = $config->{"chart-subname"}; } else { $chartMeta->description = "An interactive visualization from Our World In Data."; } $query = $_SERVER['QUERY_STRING']; $baseUrl = \Request::root() . "/" . $chart->slug; $canonicalUrl = $baseUrl; $imageUrl = $baseUrl . ".png"; if ($query != '') { $canonicalUrl .= "?" . $query; $imageUrl .= "?" . $query; } $chartMeta->imageUrl = $imageUrl; $chartMeta->canonicalUrl = $canonicalUrl; // Give the image exporter a head start on the request for imageUrl if (!str_contains(\Request::path(), ".export")) { Chart::exportPNGAsync($chart->slug, $_SERVER['QUERY_STRING'] . "&size=1000x700", 1000, 700); } return view('view.show', compact('chart', 'config', 'data', 'canonicalUrl', 'chartMeta')); } else { return 'No chart found to view'; } }