@@ -20,8 +20,7 @@ discard block |
||
| 20 | 20 | { |
| 21 | 21 | // replace API |
| 22 | 22 | $registrationIds = array($to); |
| 23 | - $msg = array |
|
| 24 | - ( |
|
| 23 | + $msg = array( |
|
| 25 | 24 | 'message' => $message, |
| 26 | 25 | 'title' => $title, |
| 27 | 26 | 'vibrate' => 1, |
@@ -29,14 +28,12 @@ discard block |
||
| 29 | 28 | |
| 30 | 29 | // you can also add images, additionalData |
| 31 | 30 | ); |
| 32 | - $fields = array |
|
| 33 | - ( |
|
| 31 | + $fields = array( |
|
| 34 | 32 | 'registration_ids' => $registrationIds, |
| 35 | 33 | 'data' => $msg |
| 36 | 34 | ); |
| 37 | - $headers = array |
|
| 38 | - ( |
|
| 39 | - 'Authorization: key=' . config('app.gcm_key'), |
|
| 35 | + $headers = array( |
|
| 36 | + 'Authorization: key='.config('app.gcm_key'), |
|
| 40 | 37 | 'Content-Type: application/json' |
| 41 | 38 | ); |
| 42 | 39 | $ch = curl_init(); |
@@ -60,14 +57,14 @@ discard block |
||
| 60 | 57 | public function handle(OkEvent $event) |
| 61 | 58 | { |
| 62 | 59 | // |
| 63 | - \Log::info('Meeting correctly optimised (company id = ' . $event->getCompany()->id . ')'); |
|
| 60 | + \Log::info('Meeting correctly optimised (company id = '.$event->getCompany()->id.')'); |
|
| 64 | 61 | $company = $event->getCompany()->fresh(); |
| 65 | 62 | //send email to company |
| 66 | 63 | self::sendCompanyEmail($company->email); |
| 67 | 64 | //send emails to employees |
| 68 | - $employees = $company->employees()->with(['meetings'=>function($query){ |
|
| 65 | + $employees = $company->employees()->with([ 'meetings'=>function($query) { |
|
| 69 | 66 | $query->where('start_time', '>=', new \DateTime()); |
| 70 | - }])->get(); |
|
| 67 | + } ])->get(); |
|
| 71 | 68 | foreach ($employees as $employee) |
| 72 | 69 | self::sendEmployeeEmail($employee->email, $employee->meetings); |
| 73 | 70 | } |
@@ -77,7 +74,7 @@ discard block |
||
| 77 | 74 | */ |
| 78 | 75 | static private function sendCompanyEmail($email) |
| 79 | 76 | { |
| 80 | - \Mail::queue('emails.optimise.ok.company', [], function ($message) use ($email) { |
|
| 77 | + \Mail::queue('emails.optimise.ok.company', [ ], function($message) use ($email) { |
|
| 81 | 78 | $message->from(config('mail.from.address'), config('mail.from.name')); |
| 82 | 79 | $message->to($email)->subject('Meetings optimised'); |
| 83 | 80 | }); |
@@ -89,7 +86,7 @@ discard block |
||
| 89 | 86 | */ |
| 90 | 87 | static private function sendEmployeeEmail($email, $meetings) |
| 91 | 88 | { |
| 92 | - \Mail::queue('emails.optimise.ok.employee', ['meetings' => $meetings], function ($message) use ($email) { |
|
| 89 | + \Mail::queue('emails.optimise.ok.employee', [ 'meetings' => $meetings ], function($message) use ($email) { |
|
| 93 | 90 | $message->from(config('mail.from.address'), config('mail.from.name')); |
| 94 | 91 | $message->to($email)->subject('Meetings of next week'); |
| 95 | 92 | }); |