@@ -31,7 +31,7 @@ |
||
| 31 | 31 | public function rules() |
| 32 | 32 | { |
| 33 | 33 | return [ |
| 34 | - 'id' => 'required|array|exists:employees,id,company_id,' . $this->user()->id, |
|
| 34 | + 'id' => 'required|array|exists:employees,id,company_id,'.$this->user()->id, |
|
| 35 | 35 | ]; |
| 36 | 36 | } |
| 37 | 37 | } |
@@ -31,9 +31,9 @@ |
||
| 31 | 31 | public function rules() |
| 32 | 32 | { |
| 33 | 33 | return [ |
| 34 | - 'name' => 'required|max:255|unique:groups,name,' . $this->route('groups') . ',id,company_id,' . $this->user()->id, |
|
| 34 | + 'name' => 'required|max:255|unique:groups,name,'.$this->route('groups').',id,company_id,'.$this->user()->id, |
|
| 35 | 35 | 'description' => 'sometimes|required|max:255', |
| 36 | - 'planner_id' => 'required|exists:employees,id,company_id,' . $this->user()->id, |
|
| 36 | + 'planner_id' => 'required|exists:employees,id,company_id,'.$this->user()->id, |
|
| 37 | 37 | ]; |
| 38 | 38 | } |
| 39 | 39 | } |
@@ -26,7 +26,7 @@ |
||
| 26 | 26 | public function handle(ErrorEvent $event) |
| 27 | 27 | { |
| 28 | 28 | // |
| 29 | - \Log::info('problems during caldav (calendar id = ' . $event->getCalendar()->calendar_id . ') sync: ' . $event->getError()); |
|
| 29 | + \Log::info('problems during caldav (calendar id = '.$event->getCalendar()->calendar_id.') sync: '.$event->getError()); |
|
| 30 | 30 | $calendar = $event->getCalendar(); |
| 31 | 31 | //$calendar = $event->getCalendar()->fresh(); |
| 32 | 32 | $calendar->sync_errors = $event->getError(); |
@@ -31,8 +31,9 @@ |
||
| 31 | 31 | self::sendCompanyEmail($company->email); |
| 32 | 32 | //send emails to employees |
| 33 | 33 | $employees = $company->employees()->with('meetings')->get(); |
| 34 | - foreach ($employees as $employee) |
|
| 35 | - self::sendEmployeeEmail($employee->email, $employee->meetings); |
|
| 34 | + foreach ($employees as $employee) { |
|
| 35 | + self::sendEmployeeEmail($employee->email, $employee->meetings); |
|
| 36 | + } |
|
| 36 | 37 | } |
| 37 | 38 | |
| 38 | 39 | /** |
@@ -49,6 +49,10 @@ discard block |
||
| 49 | 49 | }); |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | + /** |
|
| 53 | + * @param string $title |
|
| 54 | + * @param string $message |
|
| 55 | + */ |
|
| 52 | 56 | static private function sendPushs($title, $message, $additionalData = '') |
| 53 | 57 | { |
| 54 | 58 | $clients = explode(';', config('app.gcm_clients')); |
@@ -58,6 +62,9 @@ discard block |
||
| 58 | 62 | //self::sendPushNotification($clients, $message, $title); |
| 59 | 63 | } |
| 60 | 64 | |
| 65 | + /** |
|
| 66 | + * @param string $additionalData |
|
| 67 | + */ |
|
| 61 | 68 | static private function sendPushNotification($to, $message, $title, $additionalData) |
| 62 | 69 | { |
| 63 | 70 | // replace API |
@@ -25,15 +25,15 @@ discard block |
||
| 25 | 25 | public function handle(OkEvent $event) |
| 26 | 26 | { |
| 27 | 27 | // |
| 28 | - \Log::info('Meeting correctly optimised (company id = ' . $event->getCompany()->id . ')'); |
|
| 28 | + \Log::info('Meeting correctly optimised (company id = '.$event->getCompany()->id.')'); |
|
| 29 | 29 | $company = $event->getCompany()->fresh(); |
| 30 | 30 | //send email to company |
| 31 | 31 | self::sendCompanyEmail($company->email); |
| 32 | 32 | //send emails to employees |
| 33 | - $employees = $company->employees()->with(['meetings'=>function($query){ |
|
| 33 | + $employees = $company->employees()->with([ 'meetings'=>function($query) { |
|
| 34 | 34 | $query->where('start_time', '>=', new \DateTime()); |
| 35 | - }])->get(); |
|
| 36 | - self::sendPushs('New meeting scheduled', $employees->get(0)->meetings->get(0)['title'] . ' - ' . $employees->get(0)->meetings->get(0)['start_time'], $employees->get(0)->meetings->get(0)['id']); |
|
| 35 | + } ])->get(); |
|
| 36 | + self::sendPushs('New meeting scheduled', $employees->get(0)->meetings->get(0)[ 'title' ].' - '.$employees->get(0)->meetings->get(0)[ 'start_time' ], $employees->get(0)->meetings->get(0)[ 'id' ]); |
|
| 37 | 37 | foreach ($employees as $employee) |
| 38 | 38 | self::sendEmployeeEmail($employee->email, $employee->meetings); |
| 39 | 39 | } |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | static private function sendCompanyEmail($email) |
| 45 | 45 | { |
| 46 | - \Mail::queue('emails.optimise.ok.company', [], function ($message) use ($email) { |
|
| 46 | + \Mail::queue('emails.optimise.ok.company', [ ], function($message) use ($email) { |
|
| 47 | 47 | $message->from(config('mail.from.address'), config('mail.from.name')); |
| 48 | 48 | $message->to($email)->subject('Meetings optimised'); |
| 49 | 49 | }); |
@@ -63,8 +63,7 @@ discard block |
||
| 63 | 63 | // replace API |
| 64 | 64 | //\Log::info('GCM registration id: ' . $to); |
| 65 | 65 | $registrationIds = array($to); |
| 66 | - $msg = array |
|
| 67 | - ( |
|
| 66 | + $msg = array( |
|
| 68 | 67 | 'message' => $message, |
| 69 | 68 | 'title' => $title, |
| 70 | 69 | 'vibrate' => 1, |
@@ -73,14 +72,12 @@ discard block |
||
| 73 | 72 | |
| 74 | 73 | // you can also add images, additionalData |
| 75 | 74 | ); |
| 76 | - $fields = array |
|
| 77 | - ( |
|
| 75 | + $fields = array( |
|
| 78 | 76 | 'registration_ids' => $registrationIds, |
| 79 | 77 | 'data' => $msg |
| 80 | 78 | ); |
| 81 | - $headers = array |
|
| 82 | - ( |
|
| 83 | - 'Authorization: key=' . config('app.gcm_key'), |
|
| 79 | + $headers = array( |
|
| 80 | + 'Authorization: key='.config('app.gcm_key'), |
|
| 84 | 81 | 'Content-Type: application/json' |
| 85 | 82 | ); |
| 86 | 83 | $ch = curl_init(); |
@@ -93,7 +90,7 @@ discard block |
||
| 93 | 90 | $result = curl_exec($ch); |
| 94 | 91 | curl_close($ch); |
| 95 | 92 | //echo $result; |
| 96 | - \Log::info('GCM results: ' . $result); |
|
| 93 | + \Log::info('GCM results: '.$result); |
|
| 97 | 94 | } |
| 98 | 95 | |
| 99 | 96 | /** |
@@ -102,7 +99,7 @@ discard block |
||
| 102 | 99 | */ |
| 103 | 100 | static private function sendEmployeeEmail($email, $meetings) |
| 104 | 101 | { |
| 105 | - \Mail::queue('emails.optimise.ok.employee', ['meetings' => $meetings], function ($message) use ($email) { |
|
| 102 | + \Mail::queue('emails.optimise.ok.employee', [ 'meetings' => $meetings ], function($message) use ($email) { |
|
| 106 | 103 | $message->from(config('mail.from.address'), config('mail.from.name')); |
| 107 | 104 | $message->to($email)->subject('Meetings of next week'); |
| 108 | 105 | }); |
@@ -56,7 +56,7 @@ |
||
| 56 | 56 | */ |
| 57 | 57 | public function verifyEmployee(Employee $employee) |
| 58 | 58 | { |
| 59 | - $group = $this->groupsManaged()->whereHas('employees', function ($query) use ($employee) { |
|
| 59 | + $group = $this->groupsManaged()->whereHas('employees', function($query) use ($employee) { |
|
| 60 | 60 | $query->where('employees.id', $employee->id); |
| 61 | 61 | })->first(); |
| 62 | 62 | |
@@ -12,8 +12,8 @@ discard block |
||
| 12 | 12 | { |
| 13 | 13 | public function __construct() |
| 14 | 14 | { |
| 15 | - config(['auth.model' => Planner::class]); |
|
| 16 | - config(['jwt.user' => Planner::class]); |
|
| 15 | + config([ 'auth.model' => Planner::class ]); |
|
| 16 | + config([ 'jwt.user' => Planner::class ]); |
|
| 17 | 17 | $this->middleware('jwt.authandrefresh:mode-en'); |
| 18 | 18 | } |
| 19 | 19 | |
@@ -32,16 +32,16 @@ discard block |
||
| 32 | 32 | $planner = \Auth::user(); |
| 33 | 33 | $groups = $planner->groupsManaged(); |
| 34 | 34 | if ($request->query('current')) |
| 35 | - $groups->with(['meetings' => function ($query) { |
|
| 36 | - $query->where(function ($query) { //parenthesis for conditions ...(C1 OR C2)... |
|
| 37 | - $query->where('start_time', '=', NULL);//to be planned |
|
| 35 | + $groups->with([ 'meetings' => function($query) { |
|
| 36 | + $query->where(function($query) { //parenthesis for conditions ...(C1 OR C2)... |
|
| 37 | + $query->where('start_time', '=', NULL); //to be planned |
|
| 38 | 38 | //datetime to consider timezone, don't use mysql NOW() |
| 39 | - $query->orWhere('start_time', '>=', new \DateTime());//planned |
|
| 39 | + $query->orWhere('start_time', '>=', new \DateTime()); //planned |
|
| 40 | 40 | }); |
| 41 | - }]); |
|
| 41 | + } ]); |
|
| 42 | 42 | else |
| 43 | 43 | $groups->with('meetings'); |
| 44 | - return $groups->get();//both planed and to be planned |
|
| 44 | + return $groups->get(); //both planed and to be planned |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | /** |
@@ -31,16 +31,19 @@ |
||
| 31 | 31 | */ |
| 32 | 32 | $planner = \Auth::user(); |
| 33 | 33 | $groups = $planner->groupsManaged(); |
| 34 | - if ($request->query('current')) |
|
| 35 | - $groups->with(['meetings' => function ($query) { |
|
| 34 | + if ($request->query('current')) { |
|
| 35 | + $groups->with(['meetings' => function ($query) { |
|
| 36 | 36 | $query->where(function ($query) { //parenthesis for conditions ...(C1 OR C2)... |
| 37 | - $query->where('start_time', '=', NULL);//to be planned |
|
| 37 | + $query->where('start_time', '=', NULL); |
|
| 38 | + } |
|
| 39 | + //to be planned |
|
| 38 | 40 | //datetime to consider timezone, don't use mysql NOW() |
| 39 | 41 | $query->orWhere('start_time', '>=', new \DateTime());//planned |
| 40 | 42 | }); |
| 41 | 43 | }]); |
| 42 | - else |
|
| 43 | - $groups->with('meetings'); |
|
| 44 | + else { |
|
| 45 | + $groups->with('meetings'); |
|
| 46 | + } |
|
| 44 | 47 | return $groups->get();//both planed and to be planned |
| 45 | 48 | } |
| 46 | 49 | |
@@ -4,7 +4,6 @@ |
||
| 4 | 4 | |
| 5 | 5 | use Illuminate\Http\Request; |
| 6 | 6 | |
| 7 | -use plunner\Http\Requests; |
|
| 8 | 7 | use plunner\Http\Controllers\Controller; |
| 9 | 8 | |
| 10 | 9 | class GroupsController extends Controller |
@@ -11,8 +11,8 @@ discard block |
||
| 11 | 11 | { |
| 12 | 12 | public function __construct() |
| 13 | 13 | { |
| 14 | - config(['auth.model' => \plunner\Employee::class]); |
|
| 15 | - config(['jwt.user' => \plunner\Employee::class]); |
|
| 14 | + config([ 'auth.model' => \plunner\Employee::class ]); |
|
| 15 | + config([ 'jwt.user' => \plunner\Employee::class ]); |
|
| 16 | 16 | $this->middleware('jwt.authandrefresh:mode-en'); |
| 17 | 17 | } |
| 18 | 18 | |
@@ -27,10 +27,10 @@ discard block |
||
| 27 | 27 | $employee = \Auth::user(); |
| 28 | 28 | $meetings = $employee->meetings(); |
| 29 | 29 | if ($request->query('current')) |
| 30 | - $meetings->where(function ($query) { //parenthesis for conditions ...(C1 OR C2)... |
|
| 31 | - $query->where('start_time', '=', NULL);//to be planned |
|
| 30 | + $meetings->where(function($query) { //parenthesis for conditions ...(C1 OR C2)... |
|
| 31 | + $query->where('start_time', '=', NULL); //to be planned |
|
| 32 | 32 | //datetime to consider timezone, don't use mysql NOW() |
| 33 | - $query->orWhere('start_time', '>=', new \DateTime());//planned |
|
| 33 | + $query->orWhere('start_time', '>=', new \DateTime()); //planned |
|
| 34 | 34 | }); |
| 35 | 35 | return $meetings->get(); |
| 36 | 36 | } |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | |
| 73 | 73 | private static function getImg(Meeting $meeting) |
| 74 | 74 | { |
| 75 | - $name = 'meetings/' . $meeting->id; |
|
| 75 | + $name = 'meetings/'.$meeting->id; |
|
| 76 | 76 | if (!\Storage::exists($name)) |
| 77 | 77 | return false; |
| 78 | 78 | return \Storage::get($name); |
@@ -26,9 +26,11 @@ discard block |
||
| 26 | 26 | { |
| 27 | 27 | $employee = \Auth::user(); |
| 28 | 28 | $meetings = $employee->meetings(); |
| 29 | - if ($request->query('current')) |
|
| 30 | - $meetings->where(function ($query) { //parenthesis for conditions ...(C1 OR C2)... |
|
| 31 | - $query->where('start_time', '=', NULL);//to be planned |
|
| 29 | + if ($request->query('current')) { |
|
| 30 | + $meetings->where(function ($query) { //parenthesis for conditions ...(C1 OR C2)... |
|
| 31 | + $query->where('start_time', '=', NULL); |
|
| 32 | + } |
|
| 33 | + //to be planned |
|
| 32 | 34 | //datetime to consider timezone, don't use mysql NOW() |
| 33 | 35 | $query->orWhere('start_time', '>=', new \DateTime());//planned |
| 34 | 36 | }); |
@@ -63,9 +65,10 @@ discard block |
||
| 63 | 65 | $this->authorize($meeting); |
| 64 | 66 | $ret = self::getImg($meeting); |
| 65 | 67 | $blank = storage_path('img/meetings.jpg'); |
| 66 | - if ($ret === false) |
|
| 67 | - return (new Response(file_get_contents($blank), 200)) |
|
| 68 | + if ($ret === false) { |
|
| 69 | + return (new Response(file_get_contents($blank), 200)) |
|
| 68 | 70 | ->header('Content-Type', 'image/jpeg'); |
| 71 | + } |
|
| 69 | 72 | return (new Response($ret, 200)) |
| 70 | 73 | ->header('Content-Type', 'image/jpeg'); |
| 71 | 74 | } |
@@ -73,8 +76,9 @@ discard block |
||
| 73 | 76 | private static function getImg(Meeting $meeting) |
| 74 | 77 | { |
| 75 | 78 | $name = 'meetings/' . $meeting->id; |
| 76 | - if (!\Storage::exists($name)) |
|
| 77 | - return false; |
|
| 79 | + if (!\Storage::exists($name)) { |
|
| 80 | + return false; |
|
| 81 | + } |
|
| 78 | 82 | return \Storage::get($name); |
| 79 | 83 | } |
| 80 | 84 | } |
@@ -10,8 +10,8 @@ discard block |
||
| 10 | 10 | { |
| 11 | 11 | public function __construct() |
| 12 | 12 | { |
| 13 | - config(['auth.model' => \plunner\Company::class]); |
|
| 14 | - config(['jwt.user' => \plunner\Company::class]); |
|
| 13 | + config([ 'auth.model' => \plunner\Company::class ]); |
|
| 14 | + config([ 'jwt.user' => \plunner\Company::class ]); |
|
| 15 | 15 | $this->middleware('jwt.authandrefresh:mode-cn'); |
| 16 | 16 | } |
| 17 | 17 | |
@@ -36,9 +36,9 @@ discard block |
||
| 36 | 36 | public function update(CompanyRequest $request) |
| 37 | 37 | { |
| 38 | 38 | $company = \Auth::user(); |
| 39 | - $input = $request->only(['name', 'password']); |
|
| 40 | - if (isset($input['password'])) |
|
| 41 | - $input['password'] = bcrypt($input['password']); |
|
| 39 | + $input = $request->only([ 'name', 'password' ]); |
|
| 40 | + if (isset($input[ 'password' ])) |
|
| 41 | + $input[ 'password' ] = bcrypt($input[ 'password' ]); |
|
| 42 | 42 | $company->update($input); |
| 43 | 43 | return $company; |
| 44 | 44 | } |
@@ -37,8 +37,9 @@ |
||
| 37 | 37 | { |
| 38 | 38 | $employee = \Auth::user(); |
| 39 | 39 | $input = $request->only(['name', 'password']); |
| 40 | - if (isset($input['password'])) |
|
| 41 | - $input['password'] = bcrypt($input['password']); |
|
| 40 | + if (isset($input['password'])) { |
|
| 41 | + $input['password'] = bcrypt($input['password']); |
|
| 42 | + } |
|
| 42 | 43 | $employee->update($input); |
| 43 | 44 | return $employee; |
| 44 | 45 | } |
@@ -37,8 +37,9 @@ |
||
| 37 | 37 | { |
| 38 | 38 | $employee = \Auth::user(); |
| 39 | 39 | $input = $request->only(['name', 'password']); |
| 40 | - if (isset($input['password'])) |
|
| 41 | - $input['password'] = bcrypt($input['password']); |
|
| 40 | + if (isset($input['password'])) { |
|
| 41 | + $input['password'] = bcrypt($input['password']); |
|
| 42 | + } |
|
| 42 | 43 | $employee->update($input); |
| 43 | 44 | return $employee; |
| 44 | 45 | } |
@@ -10,8 +10,8 @@ discard block |
||
| 10 | 10 | { |
| 11 | 11 | public function __construct() |
| 12 | 12 | { |
| 13 | - config(['auth.model' => \plunner\Employee::class]); |
|
| 14 | - config(['jwt.user' => \plunner\Employee::class]); |
|
| 13 | + config([ 'auth.model' => \plunner\Employee::class ]); |
|
| 14 | + config([ 'jwt.user' => \plunner\Employee::class ]); |
|
| 15 | 15 | $this->middleware('jwt.authandrefresh:mode-en'); |
| 16 | 16 | } |
| 17 | 17 | |
@@ -36,10 +36,10 @@ discard block |
||
| 36 | 36 | public function update(EmployeeRequest $request) |
| 37 | 37 | { |
| 38 | 38 | $employee = \Auth::user(); |
| 39 | - $input = $request->only(['name', 'password']); |
|
| 39 | + $input = $request->only([ 'name', 'password' ]); |
|
| 40 | 40 | //TODO authorize??? |
| 41 | - if (isset($input['password'])) |
|
| 42 | - $input['password'] = bcrypt($input['password']); |
|
| 41 | + if (isset($input[ 'password' ])) |
|
| 42 | + $input[ 'password' ] = bcrypt($input[ 'password' ]); |
|
| 43 | 43 | $employee->update($input); |
| 44 | 44 | return $employee; |
| 45 | 45 | } |