当前位置: 首页>>代码示例>>PHP>>正文


PHP Setting::whereName方法代码示例

本文整理汇总了PHP中app\Setting::whereName方法的典型用法代码示例。如果您正苦于以下问题:PHP Setting::whereName方法的具体用法?PHP Setting::whereName怎么用?PHP Setting::whereName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\Setting的用法示例。


在下文中一共展示了Setting::whereName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: update

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function update(SettingRequest $request)
 {
     foreach ($request->all() as $name => $value) {
         if ($name != '_method' && $name != '_token') {
             $setting = Setting::whereName($name)->first();
             $setting->update(['value' => $value]);
         }
     }
     //更新设置缓存
     \Cache::forget('settings_array');
     return redirect('admin/settings/index');
 }
开发者ID:kpaxer,项目名称:laravel-blog,代码行数:17,代码来源:SettingsController.php

示例2: postSettings

 public function postSettings(Request $request)
 {
     $user_id = Auth::user()->id;
     $input = $request->all();
     $validator = Validator::make($input, ['custom_domain' => 'required']);
     if ($validator->passes()) {
         $data['customer_id'] = $user_id;
         $data['name'] = 'custom_domain';
         $data['value'] = removeSchemaUrl($input['custom_domain']);
         $setting = Setting::whereName('custom_domain')->where('customer_id', '=', $user_id)->first();
         if (!$setting) {
             Setting::create($data);
         } else {
             $setting->value = $data['value'];
             $setting->save();
         }
         return redirect()->back()->with("status", "Settings updated successfully");
     } else {
         return redirect()->back()->withErrors($validator)->withInput();
     }
 }
开发者ID:abrarjahin,项目名称:Laravel_5.1_test_project_to_look_at,代码行数:21,代码来源:AdminAreaController.php

示例3: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request, $webinarId)
 {
     ini_set("max_execution_time", 0);
     try {
         $webinar = Webinar::find($webinarId);
         $webinar_uuid = hashWebinar($webinarId);
         $user_id = Auth::user()->id;
         $subscribers_lists = $webinar->subscribers_lists()->get();
         $webinar_signup_subscribers_lists = $webinar->signup_subscribers_lists()->get();
         $input = $request->all();
         if (count($subscribers_lists) > 0) {
             $subject = $input['subject'];
             $body = $input['content'];
             $smtp_method = $input['smtp_method'][0];
             $setting = Setting::whereName('custom_domain')->where('customer_id', '=', $user_id)->first();
             if (!$setting) {
                 return redirect()->back()->with("error", "Custom Domain is not Set.");
             }
             $smtp = Smtp::find($smtp_method);
             if (!$smtp) {
                 return redirect()->back()->with("error", "No SMTP Method Found");
             }
             $custom_domain = $setting->value;
             config(["mail.driver" => "smtp", "mail.host" => $smtp->host, "mail.port" => $smtp->port, "mail.from.address" => $smtp->from_email, "mail.from.name" => $smtp->from_name, "mail.encryption" => $smtp->protocol, "mail.username" => $smtp->username, "mail.password" => $smtp->password]);
             // General Subscribers List
             if ($subscribers_lists) {
                 foreach ($subscribers_lists as $subscriber_list) {
                     $subscribers = $subscriber_list->activeSubscribers()->get();
                     if (count($subscribers) > 0) {
                         foreach ($subscribers as $subscriber) {
                             $subscriber_hash = $subscriber->uuid;
                             $subscriber_name = $subscriber->first_name . ' ' . $subscriber->last_name;
                             $to_email = $subscriber->email;
                             $webinar_url = "http://" . $custom_domain . "/webinar/" . $webinar_uuid . "/" . $subscriber_hash;
                             $emailData = ['body' => $body, 'subscriber_name' => $subscriber_name, 'webinar_url' => $webinar_url];
                             Mail::send('emails.webinar_invite_email', $emailData, function ($message) use($subject, $to_email, $subscriber_name) {
                                 $message->subject($subject);
                                 $message->from('admin@example.com', 'Webinar Admin');
                                 $message->to($to_email, $subscriber_name);
                             });
                         }
                     }
                 }
             }
             // Send Email to Webinar Specific Subscribers
             if ($webinar_signup_subscribers_lists) {
                 foreach ($webinar_signup_subscribers_lists as $subscriber_list) {
                     $subscribers = $subscriber_list->activeSubscribers()->get();
                     if (count($subscribers) > 0) {
                         foreach ($subscribers as $subscriber) {
                             echo $subscriber->id . "<br/>";
                             $subscriber_hash = $subscriber->uuid;
                             $subscriber_name = $subscriber->first_name . ' ' . $subscriber->last_name;
                             $to_email = $subscriber->email;
                             $webinar_url = "http://" . $custom_domain . "/webinar/" . $webinar_uuid . "/" . $subscriber_hash;
                             $emailData = ['body' => $body, 'subscriber_name' => $subscriber_name, 'webinar_url' => $webinar_url];
                             Mail::send('emails.webinar_invite_email', $emailData, function ($message) use($subject, $to_email, $subscriber_name) {
                                 $message->subject($subject);
                                 $message->to($to_email, $subscriber_name);
                             });
                         }
                     }
                 }
             }
         }
         return redirect()->back()->with("status", "Mail Sent Succesfully");
     } catch (\Exception $e) {
     }
     return redirect()->back();
 }
开发者ID:abrarjahin,项目名称:Laravel_5.1_test_project_to_look_at,代码行数:76,代码来源:EmailsController.php

示例4: postEmailNotification

 public function postEmailNotification(Request $request, $userId, $webinarUUId)
 {
     ini_set("max_execution_time", 0);
     $input = $request->all();
     $webinar = Webinar::whereId($webinarUUId)->first();
     $webinar_uuid = $webinar->uuid;
     $subscribers_lists = $webinar->subscribers_lists()->get();
     $webinar_signup_subscribers_lists = $webinar->signup_subscribers_lists()->get();
     $setting = Setting::whereName('custom_domain')->where('customer_id', '=', $userId)->first();
     if (!$setting) {
         return redirect()->back()->with("error", "Custom Domain is not Set.");
     }
     $custom_domain = $setting->value;
     $rules = ["subject" => "required", "content" => "required", "smtp_method" => "required", "send_type" => "required"];
     $validator = Validator::make($input, $rules);
     if ($validator->passes()) {
         $send_type = $input["send_type"];
         $input['customer_id'] = $userId;
         $input['smtp_setting_id'] = $input['smtp_method'];
         $smtp = Smtp::find($input['smtp_method']);
         if (!$smtp) {
             return redirect()->back()->with("error", "No SMTP Method Found");
         }
         unset($input['smtp_method']);
         if ($send_type == "now") {
             $input['send_date'] = Carbon::now();
             $input['minutes_before_webinar'] = NULL;
         } else {
             if ($send_type == "minutes_before") {
                 $minutes_before_webinar = $input['minutes_before_webinar'];
                 $input['send_date'] = Carbon::parse($webinar->starts_on)->subMinutes($minutes_before_webinar);
                 $input['minutes_before_webinar'] = $minutes_before_webinar;
             }
         }
         $count_subscribers = 0;
         $input['webinar_id'] = $webinar->id;
         $email_notification = EmailNotification::create($input);
         $email_notification->uuid = hashCampaignEmail($email_notification->id);
         $email_notification->save();
         $subject = $input['subject'];
         $body = $input['content'];
         if ($send_type == "now") {
             // Send Instant Email
             config(["mail.driver" => "smtp", "mail.host" => $smtp->host, "mail.port" => $smtp->port, "mail.from.address" => $smtp->from_email, "mail.from.name" => $smtp->from_name, "mail.encryption" => $smtp->protocol, "mail.username" => $smtp->username, "mail.password" => $smtp->password]);
             try {
                 // General Subscribers List
                 if ($subscribers_lists) {
                     foreach ($subscribers_lists as $subscriber_list) {
                         $subscribers = $subscriber_list->activeSubscribers()->get();
                         if (count($subscribers) > 0) {
                             $count_subscribers += count($subscribers);
                             foreach ($subscribers as $subscriber) {
                                 $subscriber_hash = $subscriber->uuid;
                                 $subscriber_name = $subscriber->first_name . ' ' . $subscriber->last_name;
                                 $to_email = $subscriber->email;
                                 $webinar_url = "http://" . $custom_domain . "/webinar/" . $webinar_uuid . "/" . $subscriber_hash;
                                 $emailData = ['body' => $body, 'subscriber_name' => $subscriber_name, 'webinar_url' => $webinar_url];
                                 //pr($emailData); die;
                                 Mail::send('emails.webinar_invite_email', $emailData, function ($message) use($subject, $to_email, $subscriber_name) {
                                     $message->subject($subject);
                                     $message->from('admin@example.com', 'Webinar Admin');
                                     $message->to($to_email, $subscriber_name);
                                 });
                             }
                         }
                     }
                 }
                 // Send Email to Webinar Specific Subscribers
                 if ($webinar_signup_subscribers_lists) {
                     foreach ($webinar_signup_subscribers_lists as $subscriber_list) {
                         $subscribers = $subscriber_list->activeSubscribers()->get();
                         if (count($subscribers) > 0) {
                             $count_subscribers += count($subscribers);
                             foreach ($subscribers as $subscriber) {
                                 $subscriber_hash = $subscriber->uuid;
                                 $subscriber_name = $subscriber->first_name . ' ' . $subscriber->last_name;
                                 $to_email = $subscriber->email;
                                 $webinar_url = "http://" . $custom_domain . "/webinar/" . $webinar_uuid . "/" . $subscriber_hash;
                                 $emailData = ['body' => $body, 'subscriber_name' => $subscriber_name, 'webinar_url' => $webinar_url];
                                 Mail::send('emails.webinar_invite_email', $emailData, function ($message) use($subject, $to_email, $subscriber_name) {
                                     $message->subject($subject);
                                     $message->to($to_email, $subscriber_name);
                                 });
                             }
                         }
                     }
                 }
                 // Mail Sent Successfully
                 $email_notification->count_subscribers = $count_subscribers;
                 $email_notification->status = 1;
                 $email_notification->save();
             } catch (\Exception $e) {
                 // Error in Sending Mail
                 $email_notification->status = -1;
                 $email_notification->save();
             }
         }
         return redirect()->back()->with('status', "Email Notification updated successfully");
     } else {
         return redirect()->back()->withErrors($validator)->withInput();
//.........这里部分代码省略.........
开发者ID:abrarjahin,项目名称:Laravel_5.1_test_project_to_look_at,代码行数:101,代码来源:WebinarsController.php


注:本文中的app\Setting::whereName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。