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


PHP Subscriber::where方法代码示例

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


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

示例1: getRecharge

 public function getRecharge()
 {
     $accounts = Subscriber::where('is_admin', 0)->where(function ($query) {
         $query->where('plan_type', PREPAID_PLAN)->orWhere('plan_type', FREE_PLAN);
     })->orderby('uname')->lists('uname', 'id');
     return View::make('admin.refill_coupons.recharge')->with('accounts', $accounts);
 }
开发者ID:guilhermefilippo,项目名称:access-manager,代码行数:7,代码来源:RefillController.php

示例2: doApplySubscriber

 public function doApplySubscriber()
 {
     $validator = Validator::make(array('email' => trim(Input::get('email'))), array('email' => 'required|email|min:6|max:32'));
     if ($validator->fails()) {
         return Response::json(array('status' => false));
     }
     $existed = Subscriber::where('email', trim(Input::get('email')))->first();
     if ($existed) {
         return Response::json(array('status' => false, 'exist' => true));
     }
     Subscriber::create(array('email' => trim(Input::get('email'))));
     return Response::json(array('status' => true));
 }
开发者ID:OlesKashchenko,项目名称:SkillsProject1,代码行数:13,代码来源:ApplyController.php

示例3: postResetPassword

 public function postResetPassword()
 {
     $pword = Input::get('npword');
     $id = Input::get('id');
     $affectedRows = Subscriber::where('id', $id)->update(['pword' => Hash::make($pword), 'clear_pword' => $pword]);
     if ($affectedRows) {
         $this->notifySuccess("Password Changed.");
     } else {
         $this->notifyError("Failed to change password.");
     }
     return Redirect::back();
 }
开发者ID:guilhermefilippo,项目名称:access-manager,代码行数:12,代码来源:AccountsController.php

示例4: function

 Route::post('dashboard/lists/remove-from-list/{id}', 'ListController@remove_subscribers_from_list');
 Route::get('dashboard/lists/export-list/{id}', 'ListController@export_list_csv');
 Route::get('dashboard/lists/compose-form', function () {
     return View::make('dashboard.ajax.compose-list-email', array('user' => Sentry::getUser()));
 });
 Route::post('dashboard/lists/fetch-subs/{num}', 'ListController@fetch_subs');
 Route::post('dashboard/lists/send-email/{num}', 'ListController@sub_send_email');
 /*
 |----------------------------------------------------------------------------
 |EMAILS
 |----------------------------------------------------------------------------
 */
 Route::get('dashboard/emails', 'EmailController@index');
 Route::post('dashboard/emails', 'EmailController@index');
 Route::get('dashboard/emails/compose-email', function () {
     $subscribers = Subscriber::where('active', '=', 1)->get();
     return View::make('dashboard.ajax.compose-emails-email', array('user' => Sentry::getUser(), 'subscribers' => $subscribers));
 });
 Route::post('dashboard/emails/move-to-drafts/{num}', 'EmailController@move_to_drafts');
 Route::post('dashboard/emails/drafts-destroy/{num}', 'EmailController@destroy_draft');
 Route::post('dashboard/emails/send-email/{num}', 'EmailController@send_email');
 Route::post('dashboard/emails/trash/{num}', 'EmailController@trash_email');
 Route::post('dashboard/emails/destroy/{num}', 'EmailController@destroy_email');
 Route::get('dashboard/emails/move-to-sent/{id}', 'EmailController@move_to_sent');
 /*
 |----------------------------------------------------------------------------
 |HELP
 |----------------------------------------------------------------------------
 */
 Route::get('dashboard/help', 'HelpController@index');
 Route::post('dashboard/help', 'HelpController@do_help');
开发者ID:shinichi81,项目名称:Laravel4-Newsletter-Application,代码行数:31,代码来源:routes.php

示例5: import_csv

 public function import_csv($num)
 {
     $input = Input::file('csvfile');
     $ext = pathinfo($input->getClientOriginalName(), PATHINFO_EXTENSION);
     $rules = array('csvfile' => 'required');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         $error = array('files' => array(array('error' => $validator->messages()->first(), 'name' => 'none', 'size' => 'none', 'url' => 'none', 'thumbnail_url' => 'none', 'delete_url' => 'none', 'delete_type' => 'DELETE')));
         return Response::json($error);
     } elseif ($ext != 'csv') {
         $error = array('files' => array(array('error' => 'Only CSV files are allowed', 'name' => 'none', 'size' => 'none', 'url' => 'none', 'thumbnail_url' => 'none', 'delete_url' => 'none', 'delete_type' => 'DELETE')));
         return Response::json($error);
     } else {
         $destination = 'imports';
         $filename = date('Y_m_d_H_i') . '_subscribers.' . $ext;
         $filepath = asset('imports/' . $filename);
         if ($input->move($destination, $filename)) {
             $csvpath = public_path() . '/imports/' . $filename;
             $processed = CsvManipulation::csvToArray($csvpath);
             $thecsv = $processed['uniqueSubscribers'];
             $rules = array('first_name' => 'required|alpha_num|max:128', 'last_name' => 'required|alpha_num|max:128', 'email' => 'required|email|max:255|unique:subscribers');
             $length = count($thecsv);
             $failedValidation = 0;
             for ($i = 0; $i < $length; $i++) {
                 $validator = Validator::make($thecsv[$i], $rules);
                 if ($validator->fails()) {
                     unset($thecsv[$i]);
                     $failedValidation++;
                 }
             }
             $newcsvarray = array_values($thecsv);
             $newlength = count($newcsvarray);
             $timestamp = date("Y-m-d H:i:s");
             $defaults = ['active' => 1, 'created_at' => $timestamp, 'updated_at' => $timestamp];
             $arrayforinsert = [];
             foreach ($newcsvarray as $key => $value) {
                 $arrayforinsert[] = array_merge($value, $defaults);
             }
             if (count($arrayforinsert) > 0) {
                 Subscriber::insert($arrayforinsert);
                 $list = Addressbook::find(1);
                 $subscribers = Subscriber::get();
                 foreach ($subscribers as $key => $subscriber) {
                     $list->subscribers()->attach($subscriber->id);
                 }
                 $successful = Subscriber::where('created_at', '=', $timestamp)->count();
                 $successMsg = "Total no. of subscribers successfully imported: <b>" . $successful . "</b><br />" . "Total no. of rows in the CSV file: <b>" . $processed['allRows'] . "</b><br />" . "Total no. of rows with the required 3 fields: <b>" . $processed['rowsWithThreeFields'] . "</b><br />" . "Total no. of unique emails in the CSV file: <b>" . $processed['noOfUniqueEmails'] . "</b><br />" . "Total no. of failed validations: <b>" . $failedValidation . "</b>";
                 $success = array('files' => array(array('success' => $successMsg, 'name' => $filename, 'size' => 'none', 'url' => $filepath, 'thumbnail_url' => 'none', 'delete_url' => 'none', 'delete_type' => 'DELETE')));
                 return Response::json($success);
             } else {
                 $error = array('files' => array(array('error' => 'None of the subscribers has been imported. Kindly try again.', 'name' => 'none', 'size' => 'none', 'url' => 'none', 'thumbnail_url' => 'none', 'delete_url' => 'none', 'delete_type' => 'DELETE')));
                 return Response::json($error);
             }
         } else {
             return Response::json(array('error' => "An error was encountered. Kindly refresh and try again."));
         }
     }
 }
开发者ID:shinichi81,项目名称:Laravel4-Newsletter-Application,代码行数:58,代码来源:SubscriberController.php

示例6: update

 public function update($id)
 {
     $maillist = Maillist::getMaillistWithSubs($id);
     $name = Jamesy\Sanitiser::trimInput(Input::get('name'));
     if ($name == $maillist->name) {
         $validation = NULL;
     } else {
         $validation = Jamesy\MyValidations::validate(['name' => $name], $this->rules);
     }
     if ($validation != NULL) {
         return Redirect::back()->withErrors($validation)->withInput();
     } else {
         $maillist->name = $name;
         $maillist->active = Input::get('active');
         $maillist->save();
         if ($maillist->active == 0) {
             $subscribers = $maillist->subscribers;
             foreach ($subscribers as $subscriber) {
                 $subscriber->active = 0;
                 $subscriber->save();
             }
         }
         if (Input::file('file')) {
             $fileValidation = Jamesy\MyValidations::validate(['file' => Input::file('file')], $this->fileSizeRules);
             if ($fileValidation != NULL) {
                 return Redirect::back()->withErrors($fileValidation)->withInput();
             } else {
                 $input = Input::file('file');
                 $ext = pathinfo($input->getClientOriginalName(), PATHINFO_EXTENSION);
                 if ($ext != 'xlt' && $ext != 'xls' && $ext != 'csv') {
                     return Redirect::back()->withIssues('You attempted the import with an invalid file. File must be Excel or CSV')->withInput();
                 } else {
                     $import = new Jamesy\Imports($input, $this->subscriberRules);
                     $importResult = $import->getInsertArray();
                     if (is_array($importResult)) {
                         $totalNum = $importResult[0];
                         $duplicatesNum = $importResult[1];
                         $passedArr = $importResult[2];
                         $passedNum = count($passedArr);
                         $failedNum = (int) $totalNum - (int) $duplicatesNum - (int) $passedNum;
                         $timestamp = $importResult[3];
                         $existingEmails = $importResult[4];
                         $newPassedArr = [];
                         if ($maillist->active == 0) {
                             foreach ($passedArr as $subscriber) {
                                 $subscriber['active'] = 0;
                                 $newPassedArr[] = $subscriber;
                             }
                         } else {
                             $newPassedArr = $passedArr;
                         }
                         if (count($newPassedArr)) {
                             Subscriber::insert($newPassedArr);
                             $generalList = Maillist::find(1);
                             $generalList->touch();
                             $maillist->touch();
                             $subscribers = Subscriber::where('created_at', $timestamp)->where('updated_at', $timestamp)->get();
                             foreach ($subscribers as $key => $subscriber) {
                                 $generalList->subscribers()->attach($subscriber->id);
                                 $maillist->subscribers()->attach($subscriber->id);
                             }
                         }
                         if (count($existingEmails)) {
                             $alreadySubs = Subscriber::with('maillists')->whereIn('email', $existingEmails)->get();
                             if (count($alreadySubs)) {
                                 foreach ($alreadySubs as $subscriber) {
                                     if (!$subscriber->maillists->contains($maillist->id)) {
                                         $maillist->subscribers()->attach($subscriber->id);
                                     }
                                     if ($maillist->active == 0) {
                                         $subscriber->active = 0;
                                         $subscriber->save();
                                     }
                                 }
                             }
                         }
                         $message = "List updated.";
                         $message .= "<br /><b>{$totalNum}</b> " . str_plural('row', $totalNum) . " found in excel file.";
                         if ($duplicatesNum) {
                             $message .= "<br /><b>{$duplicatesNum}</b> had duplicate email addresses.";
                         }
                         if ($passedNum == 1) {
                             $message .= "<br /><b>1</b> out of the <b>" . ($totalNum - $duplicatesNum) . "</b> with unique emails passed validation and was stored.";
                         } else {
                             $message .= "<br /><b>{$passedNum}</b> out of the <b>" . ($totalNum - $duplicatesNum) . "</b> with unique emails passed validation and were stored.";
                         }
                         if ($failedNum == 1) {
                             $message .= "<br /><b>1</b> out of the <b>" . ($totalNum - $duplicatesNum) . "</b> with unique emails failed validation (no first name, last name or bad email) and was NOT stored.";
                         } elseif ($failedNum > 1) {
                             $message .= "<br /><b>{$failedNum}</b> out of the <b>" . ($totalNum - $duplicatesNum) . "</b> with unique emails failed validation (no first name, last name or bad email) and were NOT stored.";
                         }
                         return Redirect::to('dashboard/lists')->withSuccess($message);
                     } else {
                         return Redirect::back()->withIssues($importResult);
                     }
                 }
             }
         } else {
             return Redirect::to('dashboard/lists')->withSuccess($maillist->active == 0 ? 'List updated. NOTE: All subscribers in the list are now inactive.' : 'List updated.');
         }
//.........这里部分代码省略.........
开发者ID:shinichi81,项目名称:Nifty-Newsletter,代码行数:101,代码来源:MaillistController.php

示例7: index

 public function index()
 {
     $minutes = 10;
     //30
     $user = Sentry::getUser();
     $sitename = Cache::remember('sitename', $minutes, function () {
         return Setting::first()->pluck('sitename');
     });
     $subscribers = Cache::remember('subscribers', $minutes, function () {
         return Subscriber::orderBy('id', 'desc')->get();
     });
     $active_subs = Cache::remember('active_subs', $minutes, function () {
         return Subscriber::where('active', '=', 1)->count();
     });
     $inactive_subs = Cache::remember('inactive_subs', $minutes, function () {
         return Subscriber::where('active', '=', 0)->count();
     });
     $percent_active = 0;
     $percent_inactive = 0;
     if ($subscribers->count() > 0) {
         $percent_active = round($active_subs / $subscribers->count() * 100);
         $percent_inactive = round($inactive_subs / $subscribers->count() * 100);
     }
     $emails_num = Cache::remember('emails_num', $minutes, function () {
         return Email::with('trackers')->count();
     });
     $email_impressions = Cache::remember('email_impressions', $minutes, function () {
         return Tracker::count();
     });
     $read_emails = Cache::remember('read_emails', $minutes, function () {
         return Tracker::where('read', '=', 1)->count();
     });
     $unread_emails = Cache::remember('unread_emails', $minutes, function () {
         return Tracker::where('read', '=', 0)->count();
     });
     $bounced_emails = Cache::remember('bounced_emails', $minutes, function () {
         return Tracker::where('bounced', '=', 1)->count();
     });
     $unsubscribed_emails = Cache::remember('unsubscribed_emails', $minutes, function () {
         return Tracker::where('unsubscribed', '=', 1)->count();
     });
     $percent_read = 0;
     $percent_unread = 0;
     $percent_bounced = 0;
     $percent_unsubscribed = 0;
     if ($email_impressions > 0) {
         $percent_read = round($read_emails / $email_impressions * 100);
         $percent_unread = round($unread_emails / $email_impressions * 100);
         $percent_bounced = round($bounced_emails / $email_impressions * 100);
         $percent_unsubscribed = round($unsubscribed_emails / $email_impressions * 100);
     }
     $browser_outof = Cache::remember('browser_outof', $minutes, function () {
         return DB::table('trackers')->select('browser', DB::raw('count(*) as total'))->groupBy('browser')->where('read', '=', 1)->orderBy('total', 'desc')->get();
     });
     $browsers_emails = Cache::remember('browsers_emails', $minutes, function () {
         return DB::table('trackers')->select('browser', DB::raw('count(*) as total'))->groupBy('browser')->where('read', '=', 1)->orderBy('total', 'desc')->take(5)->get();
     });
     $platform_outof = Cache::remember('platform_outof', $minutes, function () {
         return DB::table('trackers')->select('platform', DB::raw('count(*) as total'))->groupBy('platform')->where('read', '=', 1)->orderBy('total', 'desc')->get();
     });
     $platforms_emails = Cache::remember('platform_emails', $minutes, function () {
         return DB::table('trackers')->select('platform', DB::raw('count(*) as total'))->groupBy('platform')->where('read', '=', 1)->orderBy('total', 'desc')->take(5)->get();
     });
     $percent_browsers = [];
     $percent_platforms = [];
     if ($read_emails > 0) {
         foreach ($browsers_emails as $key => $browser) {
             $percent_browsers[] = round($browser->total / $read_emails * 100);
         }
         foreach ($platforms_emails as $key => $platform) {
             $percent_platforms[] = round($platform->total / $read_emails * 100);
         }
     }
     $subs_unsubscribed = Cache::remember('subs_unsubscribed', $minutes, function () {
         return Tracker::where('unsubscribed', '=', 1)->groupBy('subscriber_id')->get()->count();
     });
     $self_deactivated = 0;
     if ($inactive_subs > 0) {
         $self_deactivated = round($subs_unsubscribed / $inactive_subs * 100);
     }
     $admin_deactivated = 100 - $self_deactivated;
     return View::make('dashboard.index', array('user' => $user, 'sitename' => $sitename, 'emails_num' => $emails_num, 'impressions' => $email_impressions, 'read_emails' => $percent_read, 'unread_emails' => $percent_unread, 'bounced_emails' => $percent_bounced, 'unsubscribed_emails' => $unsubscribed_emails, 'browsers_emails' => $browsers_emails, 'browser_outof' => count($browser_outof), 'browsers_array' => $percent_browsers, 'platforms_emails' => $platforms_emails, 'platform_outof' => count($platform_outof), 'platforms_array' => $percent_platforms, 'subscribers' => $subscribers, 'active_subs' => $percent_active, 'inactive_subs' => $percent_inactive, 'inactive_outof' => $inactive_subs, 'self_deactivated' => $self_deactivated, 'admin_deactivated' => $admin_deactivated));
 }
开发者ID:shinichi81,项目名称:Laravel4-Newsletter-Application,代码行数:83,代码来源:MainController.php

示例8: import

 public function import()
 {
     $validation = Jamesy\MyValidations::validate(Input::all(), $this->fileRules);
     if ($validation != NULL) {
         return Redirect::back()->withErrors($validation);
     } else {
         $input = Input::file('file');
         $ext = pathinfo($input->getClientOriginalName(), PATHINFO_EXTENSION);
         if ($ext != 'xlt' && $ext != 'xls' && $ext != 'csv') {
             return Redirect::back()->withIssues('You attempted the import with an invalid file. File must be Excel or CSV');
         } else {
             $import = new Jamesy\Imports($input, $this->rules);
             $importResult = $import->getInsertArray();
             if (is_array($importResult)) {
                 $totalNum = $importResult[0];
                 $duplicatesNum = $importResult[1];
                 $passedArr = $importResult[2];
                 $passedNum = count($passedArr);
                 $failedNum = (int) $totalNum - (int) $duplicatesNum - (int) $passedNum;
                 $timestamp = $importResult[3];
                 if (count($passedArr)) {
                     Subscriber::insert($passedArr);
                     $list = Maillist::find(1);
                     $list->touch();
                     $subscribers = Subscriber::where('created_at', $timestamp)->where('updated_at', $timestamp)->get();
                     foreach ($subscribers as $key => $subscriber) {
                         $list->subscribers()->attach($subscriber->id);
                     }
                 }
                 $message = "<b>{$totalNum}</b> " . str_plural('row', $totalNum) . " found in excel file.";
                 if ($duplicatesNum) {
                     $message .= "<br /><b>{$duplicatesNum}</b> had duplicate email addresses.";
                 }
                 if ($passedNum == 1) {
                     $message .= "<br /><b>1</b> out of the <b>" . ($totalNum - $duplicatesNum) . "</b> with unique emails passed validation and was stored.";
                 } else {
                     $message .= "<br /><b>{$passedNum}</b> out of the <b>" . ($totalNum - $duplicatesNum) . "</b> with unique emails passed validation and were stored.";
                 }
                 if ($failedNum == 1) {
                     $message .= "<br /><b>1</b> out of the <b>" . ($totalNum - $duplicatesNum) . "</b> with unique emails failed validation (no first name, last name or bad email) and was NOT stored.";
                 } elseif ($failedNum > 1) {
                     $message .= "<br /><b>{$failedNum}</b> out of the <b>" . ($totalNum - $duplicatesNum) . "</b> with unique emails failed validation (no first name, last name or bad email) and were NOT stored.";
                 }
                 return Redirect::back()->withSuccess($message);
             } else {
                 return Redirect::back()->withIssues($importResult);
             }
         }
     }
 }
开发者ID:shinichi81,项目名称:Nifty-Newsletter,代码行数:50,代码来源:SubscriberController.php

示例9: getRecharge

 public function getRecharge()
 {
     $accounts = Subscriber::where('is_admin', 0)->where('plan_type', PREPAID_PLAN)->lists('uname', 'id');
     return View::make('admin.vouchers.recharge')->with('plans', Plan::lists('name', 'id'))->with('accounts', $accounts);
 }
开发者ID:guilhermefilippo,项目名称:access-manager,代码行数:5,代码来源:VouchersController.php


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