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


PHP Company::whereRaw方法代码示例

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


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

示例1: fire

 public function fire()
 {
     $this->info(date('Y-m-d') . ' Running SendRenewalInvoices...');
     // get all accounts with plans expiring in 10 days
     $companies = Company::whereRaw('datediff(plan_expires, curdate()) = 10')->orderBy('id')->get();
     $this->info(count($companies) . ' companies found renewing in 10 days');
     foreach ($companies as $company) {
         if (!count($company->accounts)) {
             continue;
         }
         $account = $company->accounts->sortBy('id')->first();
         $plan = [];
         $plan['plan'] = $company->plan;
         $plan['term'] = $company->plan_term;
         $plan['num_users'] = $company->num_users;
         $plan['price'] = min($company->plan_price, Utils::getPlanPrice($plan));
         if ($company->pending_plan) {
             $plan['plan'] = $company->pending_plan;
             $plan['term'] = $company->pending_term;
             $plan['num_users'] = $company->pending_num_users;
             $plan['price'] = min($company->pending_plan_price, Utils::getPlanPrice($plan));
         }
         if ($plan['plan'] == PLAN_FREE || !$plan['plan'] || !$plan['term'] || !$plan['price']) {
             continue;
         }
         $client = $this->accountRepo->getNinjaClient($account);
         $invitation = $this->accountRepo->createNinjaInvoice($client, $account, $plan, 0, false);
         // set the due date to 10 days from now
         $invoice = $invitation->invoice;
         $invoice->due_date = date('Y-m-d', strtotime('+ 10 days'));
         $invoice->save();
         $term = $plan['term'];
         $plan = $plan['plan'];
         if ($term == PLAN_TERM_YEARLY) {
             $this->mailer->sendInvoice($invoice);
             $this->info("Sent {$term}ly {$plan} invoice to {$client->getDisplayName()}");
         } else {
             $this->info("Created {$term}ly {$plan} invoice for {$client->getDisplayName()}");
         }
     }
     $this->info('Done');
 }
开发者ID:hillelcoren,项目名称:invoice-ninja,代码行数:42,代码来源:SendRenewalInvoices.php


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