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


PHP Company::addNotification方法代码示例

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


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

示例1: removeByAdmin

 public function removeByAdmin($id)
 {
     $user = \User::getUser();
     if (!$user->hasAccess('admin')) {
         throw new \Exception("Not admin.", 1);
         return;
     }
     if (!($job = $this->findById($id))) {
         throw new \Exception("Job not found", 1);
         return;
     }
     $company = $job->company;
     if (!is_null($job->agency_id)) {
         $agency = $job->agency;
     }
     $tmpJob = $job;
     if ($job->delete()) {
         $notificationData = ['company_id' => $company->id, 'alert_from' => 'System: Programme Chameleon', 'has_read' => false, 'title' => 'Your job "' . $tmpJob->title . '" has been removed by admin', 'url' => null];
         $notification = \Company::addNotification($company, $notificationData);
         if (isset($agency)) {
             $notificationData = ['agency_id' => $agency->id, 'alert_from' => 'System: Programme Chameleon', 'has_read' => false, 'title' => 'Your job "' . $tmpJob->title . '" has been removed by admin', 'url' => null];
             $notification = \Agency::addNotification($agency, $notificationData);
         }
         return true;
     }
     return false;
 }
开发者ID:phantomlight,项目名称:programme-chameleon,代码行数:27,代码来源:JobProvider.php

示例2: applyForJob

 public function applyForJob($contractor, $job)
 {
     if (!($company = $job->company)) {
         throw new \Exception("Company for this job not found.", 1);
         return;
     }
     // not efficient, need to change
     if (!($contractor = $this->findById($contractor->id))) {
         throw new \Exception("Contractor not found.", 1);
         return;
     }
     if ($contractor->jobs->contains($job->id)) {
         throw new \Exception("You have already applied for this job.", 1);
         return;
     }
     $contractor->jobs()->sync([$job->id => ['status' => 'request', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]], false);
     // TODO: Move to background worker
     $cUser = $contractor->user;
     $_hash = new Hash();
     $_hash = $_hash->getHasher();
     $notificationData = ['company_id' => $company->id, 'title' => 'New Job Application', 'alert_from' => $cUser->first_name . ' ' . $cUser->last_name, 'has_read' => false, 'url' => route('company.job.application') . '?i=' . $_hash->encode($job->id)];
     $notification = \Company::addNotification($company, $notificationData);
     if (!is_null($job->agency_id)) {
         if ($agency = $job->agency) {
             $notificationData = ['agency_id' => $job->agency_id, 'title' => 'New Job Application', 'alert_from' => $cUser->first_name . ' ' . $cUser->last_name, 'has_read' => false, 'url' => route('agency.job.application') . '?i=' . $_hash->encode($job->id)];
             $notification = \Agency::addNotification($agency, $notificationData);
         }
     }
     // END TODO
     return $contractor;
 }
开发者ID:phantomlight,项目名称:programme-chameleon,代码行数:31,代码来源:ContractorProvider.php

示例3: updateExpense

 public function updateExpense($id, $agency, $status)
 {
     if (!($expense = \Contractor::findExpenseById($id))) {
         throw new \Exception("Expense not found", 1);
         return;
     }
     $job = $expense->job;
     if ($agency->id !== $job->agency_id) {
         throw new \Exception("Expense does not belong to the agency.", 1);
         return;
     }
     if ($status) {
         $expense->auth_agency = true;
         $expense->save();
         if ($contractor = $expense->contractor) {
             $notificationData = ['contractor_id' => $contractor->id, 'alert_from' => 'System: Programme Chameleon', 'has_read' => false, 'title' => 'Your expense "' . $expense->title . '" for "' . $job->title . '" has been accepted.', 'description' => 'Accepted by ' . $agency->name, 'url' => '#'];
             \Contractor::addNotification($contractor, $notificationData);
         }
         if (!is_null($job->company_id)) {
             $_hash = new Hash();
             $_hash = $_hash->getHasher();
             if ($company = \Company::findCompanyById($job->company_id)) {
                 $notificationData = ['company_id' => $company->id, 'alert_from' => 'System: Programme Chameleon', 'has_read' => false, 'title' => 'Expense "' . $expense->title . '" for "' . $job->title . '" has been accepted.', 'description' => 'Accepted by ' . $agency->name, 'url' => route('company.job.detail') . '?i=' . $_hash->encode($job->id)];
                 \Company::addNotification($company, $notificationData);
             }
         }
     } else {
         $expense->auth_agency = true;
         $expense->save();
         if ($contractor = $expense->contractor) {
             $notificationData = ['contractor_id' => $contractor->id, 'alert_from' => 'System: Programme Chameleon', 'has_read' => false, 'title' => 'Your expense "' . $expense->title . '" for "' . $job->title . '" has been de-authorized.', 'description' => 'De-authorize by ' . $agency->name, 'url' => '#'];
             \Contractor::addNotification($contractor, $notificationData);
         }
         if (!is_null($job->company_id)) {
             if ($company = \Company::findCompanyById($job->company_id)) {
                 $_hash = new Hash();
                 $_hash = $_hash->getHasher();
                 $notificationData = ['company_id' => $company->id, 'alert_from' => 'System: Programme Chameleon', 'has_read' => false, 'title' => 'Expense "' . $expense->title . '" for "' . $job->title . '" has been de-authorized.', 'description' => 'De-authorize by ' . $agency->name, 'url' => route('agency.job.detail') . '?i=' . $_hash->encode($job->id)];
                 \Company::addNotification($company, $notificationData);
             }
         }
     }
     return $expense;
 }
开发者ID:phantomlight,项目名称:programme-chameleon,代码行数:44,代码来源:AgencyProvider.php


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