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


PHP Subscription::whereRaw方法代码示例

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


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

示例1: unsubscribe

 public function unsubscribe($user_id)
 {
     $validator = Validator::make(array('id' => $user_id), array('id' => 'numeric'));
     if ($validator->fails()) {
         return $this->respondInsufficientPrivileges($validator->messages()->all());
     }
     $category_id = Input::get('category_id');
     if ($category_id) {
         $subscription = Subscription::whereRaw('user_id = ' . $user_id . ' and category_id = ' . $category_id)->first();
         if ($subscription) {
             $subscription->delete();
             return $this->respondNoContent();
         }
         return $this->respondNotFound('Subscription not found');
     }
     return $this->respondNotFound('Category not found');
 }
开发者ID:SenhorBardell,项目名称:wordotheday,代码行数:17,代码来源:UsersController.php

示例2: postCSVUpload

 public function postCSVUpload()
 {
     $input = Input::all();
     error_log(json_encode($input));
     // validation
     $rules = array('file' => 'mimes:csv,txt');
     $validation = Validator::make($input, $rules);
     if ($validation->fails()) {
         return Response::make($validation->errors->first(), 400);
     }
     // check for duplicates and move to uploads dir
     $file = Input::file('file');
     $destinationPath = 'uploads';
     $filename = $file->getClientOriginalName();
     $file_path = public_path() . '/' . $destinationPath . '/' . $filename;
     // get rid of old entries
     Emailusage::where('filename', $filename)->delete();
     // delete old file
     if (File::exists($file_path)) {
         File::delete($file_path);
     }
     // move new file
     $upload_success = Input::file('file')->move($destinationPath, $filename);
     if ($upload_success) {
         $handle = fopen($file_path, 'r');
         while (($line = fgetcsv($handle)) !== FALSE) {
             // aws account
             $curr_aws_account = $line[1];
             // 1st line of col labels
             if (!is_numeric($curr_aws_account)) {
                 //error_log($curr_aws_account." not numeric ):");
                 continue;
             }
             $cat_cmp = strcmp($line[4], 'Amazon Simple Email Service');
             if ($cat_cmp !== 0) {
                 //error_log($cat_cmp." Cat not relevant ".$line[4]);
                 continue;
             }
             $mail_service_cmp = strpos(strtolower($line[5]), strtolower('Cost per recipient of SendEmail'));
             $attachments_service_cmp = strpos(strtolower($line[5]), strtolower('Cost per GB of attachments'));
             if ($mail_service_cmp === false && $attachments_service_cmp === false) {
                 error_log($service_cmp . " Service not relevant " . $line[5]);
                 continue;
             }
             //$line is an array of the csv elements
             $num_columns = count($line);
             error_log(">>> LINE " . json_encode($line));
             // get the corresponding company_id
             $company_meta = CompanyMeta::where('type', 'aws')->where('subtype', 'auth')->where('key', 'account')->where('value', $curr_aws_account)->first();
             $company_id = -1;
             if ($company_meta) {
                 $company_id = $company_meta->company_id;
                 error_log($company_id . " Company FOUND :)");
             }
             // Error no company found
             if ($company_id === -1) {
                 error_log("Company NOT found ):");
                 continue;
             }
             // use start date for period
             $curr_period = explode(" ", $line[2])[0];
             error_log("Curr period " . $curr_period);
             // make sure day is 1st of the month
             // so that date can de used as a month tag ?
             //
             // get the subscription
             $email_subscription = Subscription::where("service_id", Config::get('eenvoudcrm.nieuwsbrieven_service_id'))->where('company_id', $company_id)->first();
             if (!$email_subscription) {
                 error_log("Consistency check falure - no nieuwsbrieven subscription (28) found");
                 continue;
             }
             $mail_bill_type = $mail_service_cmp === false ? 'attach' : 'mail';
             // search emailusage table for already existing entries
             $curr_emailusage = Emailusage::where('type', $mail_bill_type)->where('period', '=', $curr_period)->where('subscription_id', '=', $email_subscription->id)->first();
             // if they exist update
             if ($curr_emailusage) {
                 //update
                 error_log('update ' . json_encode($curr_emailusage));
                 $curr_emailusage->type = $mail_bill_type;
                 $curr_emailusage->cnt = $line[6];
                 $curr_emailusage->filename = $filename;
                 $curr_emailusage->save();
             } else {
                 // get the subscription
                 $email_subscription = Subscription::whereRaw("service_id=" . Config::get('eenvoudcrm.nieuwsbrieven_service_id') . " AND company_id={$company_id}")->first();
                 error_log('create ' . json_encode($email_subscription));
                 if ($email_subscription) {
                     $curr_emailusage = new Emailusage();
                     $curr_emailusage->type = $mail_bill_type;
                     $curr_emailusage->subscription_id = $email_subscription->id;
                     $curr_emailusage->period = $curr_period;
                     $curr_emailusage->cnt = $line[6];
                     $curr_emailusage->filename = $filename;
                     $curr_emailusage->save();
                     error_log(json_encode($curr_emailusage));
                 } else {
                     error_log("No niewsbrieven subscriptions for " . $company_id);
                 }
             }
         }
//.........这里部分代码省略.........
开发者ID:strikles,项目名称:php,代码行数:101,代码来源:AdminSubscriptionController.php


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