本文整理汇总了PHP中Settings::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Settings::where方法的具体用法?PHP Settings::where怎么用?PHP Settings::where使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Settings
的用法示例。
在下文中一共展示了Settings::where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
public function create($catalog_id)
{
$rules = array('images' => 'required');
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) {
return Redirect::route(array('admin.newsletter.create', $catalog_id))->withErrors($validator)->With(Input::all());
} else {
$catalog = Catalog::find($catalog_id);
$pictures = $catalog->pictures;
$car = $catalog->car;
$images = Input::get('images');
$newsletter = new Newsletter();
$newsletter->title = $catalog->title;
$newsletter->images = $images;
$newsletter->send_to = 0;
$newsletter->user_id = Auth::user()->id;
$newsletter->catalog_id = $catalog_id;
$newsletter->save();
$settingsEmail = Settings::where('key', '=', 'contact_email')->first();
$settingsEmailName = Settings::where('key', '=', 'contact_name')->first();
// Subscribers::find(8001) for testing
$subscribers = Subscribers::all();
foreach ($subscribers as $subscriber) {
$data = array('subject' => $catalog->title, 'to' => $subscriber->email, 'to_name' => $subscriber->name, 'from_name' => $settingsEmailName->value, 'from' => $settingsEmail->value, 'catalog' => $catalog, 'images' => $images, 'car' => $car, 'pictures' => $pictures, 'user' => $subscriber);
Mail::queue('emails.newsletter.html', $data, function ($message) use($data) {
$message->to($data['to'], $data['to_name'])->from($data['from'], $data['from_name'])->subject($data['subject']);
});
}
return Redirect::route('admin.newsletter.index')->with('success', Lang::get('messages.newsletter_created'));
}
return Redirect::route('admin.newsletter.index')->with('success', Lang::get('messages.newsletter_created'));
}
示例2: Settings
public function Settings()
{
$data['user'] = Auth::user();
if ($data['user']->access != 'Admin') {
return 'Access Denied BITCH!!!';
}
if (Input::get('submit') == 'update') {
Settings::where('name', 'default_chance')->update(['value' => Input::get('default_chance')]);
Settings::where('name', 'blockchain_info_api_code')->update(['value' => Input::get('btc_api_code')]);
Settings::where('name', 'test_mode')->update(['value' => Input::get('test_mode') ? true : false]);
Coin::where('code', 'BTC')->update(['address' => Input::get('btc_address')]);
Coin::where('code', 'AUR')->update(['address' => Input::get('aur_address')]);
Coin::where('code', 'BTC')->update(['pot' => Input::get('btc_pot')]);
Coin::where('code', 'AUR')->update(['pot' => Input::get('aur_pot')]);
if (Input::get('accounts') > 0) {
$user = User::find(Input::get('accounts'));
$user->username = Input::get('u_username');
$user->email = Input::get('u_email');
$user->btc_wallet_balance = Input::get('u_btc_balance');
$user->aur_wallet_balance = Input::get('u_aur_balance');
$user->save();
}
return Redirect::to('/')->with('alert', "Global Settings Updated!!");
} else {
if (Input::get('submit') == 'delete') {
$id = Input::get('accounts');
DB::table('users')->where('id', $id)->delete();
return Redirect::to('/')->with('alert', "Account '{$id}' Deleted");
}
}
}
示例3: sendMessage
public function sendMessage()
{
$encoded_values = Settings::where('key', 'chat')->first();
$decoded_values = json_decode($encoded_values->value);
$v_data = ["thread_id" => Input::get('thread_id'), "user_id" => Input::get('user_id'), "message" => Input::get('message'), "attachment" => Input::hasFile('attachment') ? \Str::lower(Input::file('attachment')->getClientOriginalExtension()) : ""];
$v_rules = ["thread_id" => 'required', "user_id" => 'required', "message" => 'required', "attachment" => 'in:' . $decoded_values->chat_file_types];
$v = Validator::make($v_data, $v_rules);
if ($v->passes() && Input::get("user_id") > 0 && Input::get("thread_id") > 0) {
$thread_message = new ThreadMessages();
$thread_message->thread_id = Input::get('thread_id');
$thread_message->sender_id = Input::get('user_id');
$thread_message->message = Input::get('message');
$thread_message->save();
if (Input::hasFile('attachment') && Input::file('attachment')->getSize() <= $decoded_values->max_file_size * 1024 * 1024) {
$ticket_attachment = new TicketAttachments();
$ticket_attachment->thread_id = Input::get('thread_id');
$ticket_attachment->message_id = $thread_message->id;
$ticket_attachment->has_attachment = Input::hasFile('attachment');
$ticket_attachment->attachment_path = Input::hasFile('attachment') ? Utils::fileUpload(Input::file('attachment'), 'attachments') : '';
$ticket_attachment->save();
}
return json_encode(["result" => 1]);
} else {
return json_encode(["result" => 0]);
}
}
示例4: Value
public static function Value($name)
{
if (!Settings::where('name', $name)->pluck('value')) {
Settings::insert(array('name' => $name, 'value' => 'null', 'created_at' => '', 'updated_at' => ''));
}
return Settings::where('name', $name)->pluck('value');
}
示例5: hasAnyMailchimpPermissions
static function hasAnyMailchimpPermissions()
{
$settings = json_decode(\Settings::where('key', 'mailchimp')->pluck('value'));
if ((Permissions::hasPermission('mailchimp.pair_email') || Permissions::hasPermission('mailchimp.all') || Permissions::hasPermission('mailchimp.delete')) && $settings->use_mailchimp) {
return true;
} else {
return false;
}
}
示例6: getSettingValue
public static function getSettingValue($name)
{
$setting = Settings::where('name', $name)->get()->first();
if (!empty($setting)) {
return $setting->value;
} else {
return false;
}
}
示例7: updateSettings
public function updateSettings()
{
$current_settings = Input::get('settings');
$settings = Settings::where('user_id', '=', Auth::user()->id)->first();
$settings->default_networks = json_encode($current_settings);
$settings->schedule_id = Input::get('schedule');
$settings->save();
return Redirect::to('/settings')->with('message', array('type' => 'success', 'text' => 'Settings was updated!'));
}
示例8: set
/**
* insert settings
* @param $key
* @param $value
*/
public function set($name, $value)
{
$setting = Settings::where('name', $name)->first();
if ($setting) {
$setting->value = $value;
$setting->save();
} else {
Settings::create(['name' => $name, 'value' => $value]);
}
}
示例9: getValue
public static function getValue($key)
{
if (Cache::has($key)) {
return Cache::get($key);
}
$val = Settings::where('name', '=', $key)->first();
if ($val === null) {
return null;
}
Cache::put($key, $val->value, self::TTL_CACHE);
return $val->value;
}
示例10: post
public function post()
{
if (Input::has('api_key') && Input::has('content')) {
$api_key = Input::get('api_key');
$content = Input::get('content');
$settings = Settings::where('api_key', '=', $api_key)->first();
$user_id = $settings->user_id;
$default_networks = json_decode($settings->default_networks, true);
$schedule = Carbon::now();
if (Input::has('queue')) {
$schedule_id = $settings->schedule_id;
$interval = Schedule::find($schedule_id);
if ($interval->rule == 'add') {
$schedule = $current_datetime->modify('+ ' . $interval->period);
} else {
if ($interval->rule == 'random') {
$current_day = date('d');
$from_datetime = Carbon::now();
$to_datetime = $from_datetime->copy()->modify('+ ' . $interval->period);
$days_to_add = $from_datetime->diffInDays($to_datetime);
$day = mt_rand($current_day, $current_day + $days_to_add);
$hour = mt_rand(1, 23);
$minute = mt_rand(0, 59);
$second = mt_rand(0, 59);
//year, month and timezone is null
$schedule = Carbon::create(null, null, $day, $hour, $minute, $second, null);
}
}
if (empty($schedule)) {
$schedule = $current_datetime->addHours(1);
}
}
if (!empty($default_networks)) {
$post = new Post();
$post->user_id = $user_id;
$post->content = $content;
$post->date_time = $schedule;
$post->save();
$post_id = $post->id;
foreach ($default_networks as $network_id) {
$post_network = new PostNetwork();
$post_network->user_id = $user_id;
$post_network->post_id = $post_id;
$post_network->network_id = $network_id;
$post_network->status = 1;
$post_network->save();
}
Queue::later($schedule, 'SendPost@fire', array('post_id' => $post_id));
$response_data = array('type' => 'success', 'text' => 'Your post was scheduled! It will be published on ' . $schedule->format('l jS \\o\\f F \\a\\t h:i A'));
return $response_data;
}
}
}
示例11: update
/**
* Update the specified resource in storage.
*
* @param int $id
* @return Response
*/
public function update($id)
{
if (ACL::checkUserPermission('settings.index') == false) {
return Redirect::action('dashboard');
}
$settings = Settings::where('id', $id)->find($id);
$settings->display_name = Input::get('display_name');
$settings->value = Input::get('value');
$settings->updated_at = date('Y-m-d H:i:s');
if ($settings->save()) {
$messageType = 'success';
$message = 'Setting edit success';
} else {
$messageType = 'error';
$message = 'Setting edit failed';
}
return Redirect::action('settings.index')->with($messageType, $message);
}
示例12: siteSettings
public function siteSettings()
{
if ($_POST) {
$input = Input::all();
foreach ($input as $key => $val) {
if ($key == '_token' || $key == 'savesettings') {
continue;
}
if ($setting = Settings::where('name', $key)->first()) {
$setting->value = $val;
} else {
$setting = new Settings();
$setting->name = $key;
$setting->value = htmlspecialchars($val);
}
$setting->save();
}
return Redirect::to('admin/site');
}
$settings = Settings::all();
$this->layout->content = View::make('admin.settings')->with('settings', $settings);
}
示例13: send_notifications
function send_notifications($id, $type, $title, $message, $is_imp = NULL)
{
Log::info('push notification');
$settings = Settings::where('key', 'push_notification')->first();
$push_notification = $settings->value;
if ($type == 'walker') {
$user = Walker::find($id);
} else {
$user = Owner::find($id);
}
if ($push_notification == 1 || $is_imp == "imp") {
if ($user->device_type == 'ios') {
/* WARNING:- you can't pass devicetoken as string in GCM or IOS push
* you have to pass array of devicetoken even thow it's only one device's token. */
/* send_ios_push("E146C7DCCA5EBD49803278B3EE0C1825EF0FA6D6F0B1632A19F783CB02B2617B",$title,$message,$type); */
send_ios_push($user->device_token, $title, $message, $type);
} else {
$message = json_encode($message);
send_android_push($user->device_token, $title, $message);
}
}
}
示例14: get_nearby
public function get_nearby()
{
$latitude = Input::get('latitude');
$longitude = Input::get('longitude');
$typestring = Input::get('type');
$settings = Settings::where('key', 'default_search_radius')->first();
$distance = $settings->value;
$settings = Settings::where('key', 'default_distance_unit')->first();
//$unit = $settings->value;
//if ($unit == 0) {
// $multiply = 1.609344;
//} elseif ($unit == 1) {
$multiply = 1;
// }
if ($typestring == "") {
$query = "SELECT " . "walker.id, " . "walker.first_name, " . "walker.last_name, " . "walker.latitude, " . "walker.longitude, " . "ROUND(" . $multiply . " * 3956 * acos( cos( radians('{$latitude}') ) * " . "cos( radians(latitude) ) * " . "cos( radians(longitude) - radians('{$longitude}') ) + " . "sin( radians('{$latitude}') ) * " . "sin( radians(latitude) ) ) ,8) as distance " . "from walker " . "where is_available = 1 and " . "is_active = 1 and " . "is_approved = 1 and " . "ROUND((" . $multiply . " * 3956 * acos( cos( radians('{$latitude}') ) * " . "cos( radians(latitude) ) * " . "cos( radians(longitude) - radians('{$longitude}') ) + " . "sin( radians('{$latitude}') ) * " . "sin( radians(latitude) ) ) ) ,8) <= {$distance} " . "order by distance";
} else {
$query = "SELECT " . "walker.id, " . "walker.first_name, " . "walker.last_name, " . "walker.latitude, " . "walker.longitude, " . "ROUND(" . $multiply . " * 3956 * acos( cos( radians('{$latitude}') ) * " . "cos( radians(walker.latitude) ) * " . "cos( radians(walker.longitude) - radians('{$longitude}') ) + " . "sin( radians('{$latitude}') ) * " . "sin( radians(walker.latitude) ) ) ,8) as distance " . "from walker " . "JOIN walker_services " . "where walker.is_available = 1 and " . "walker.is_active = 1 and " . "walker.is_approved = 1 and " . "ROUND((" . $multiply . " * 3956 * acos( cos( radians('{$latitude}') ) * " . "cos( radians(walker.latitude) ) * " . "cos( radians(walker.longitude) - radians('{$longitude}') ) + " . "sin( radians('{$latitude}') ) * " . "sin( radians(walker.latitude) ) ) ) ,8) <= {$distance} and " . "walker.id = walker_services.provider_id and " . "walker_services.type = {$typestring} " . "order by distance";
}
$walkers = DB::select(DB::raw($query));
// return $walkers;
foreach ($walkers as $key) {
echo "<option value=" . $key->id . ">" . $key->first_name . " " . $key->last_name . "</option>";
}
}
示例15: userForgotPassword
public function userForgotPassword()
{
$email = Input::get('email');
$owner = Owner::where('email', $email)->first();
if ($owner) {
$new_password = time();
$new_password .= rand();
$new_password = sha1($new_password);
$new_password = substr($new_password, 0, 8);
$owner->password = Hash::make($new_password);
$owner->save();
// send email
$settings = Settings::where('key', 'email_forgot_password')->first();
$pattern = $settings->value;
$pattern = str_replace('%password%', $new_password, $pattern);
$subject = "Your New Password";
email_notification($owner->id, 'owner', $pattern, $subject);
return Redirect::to('user/signin')->with('success', 'password reseted successfully. Please check your inbox for new password.');
} else {
return Redirect::to('user/signin')->with('error', 'This email ID is not registered with us');
}
}