@@ -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 | /** |
@@ -61,6 +61,10 @@ |
||
61 | 61 | }); |
62 | 62 | } |
63 | 63 | |
64 | + /** |
|
65 | + * @param string $title |
|
66 | + * @param string $message |
|
67 | + */ |
|
64 | 68 | static private function sendPushs($title, $message) |
65 | 69 | { |
66 | 70 | $clients = explode(';', config('app.gcm_key')); |
@@ -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']); |
|
35 | + } ])->get(); |
|
36 | + self::sendPushs('New meeting scheduled', $employees->get(0)->meetings->get(0)[ 'title' ].' - '.$employees->get(0)->meetings->get(0)[ 'start_time' ]); |
|
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, |
@@ -72,14 +71,12 @@ discard block |
||
72 | 71 | |
73 | 72 | // you can also add images, additionalData |
74 | 73 | ); |
75 | - $fields = array |
|
76 | - ( |
|
74 | + $fields = array( |
|
77 | 75 | 'registration_ids' => $registrationIds, |
78 | 76 | 'data' => $msg |
79 | 77 | ); |
80 | - $headers = array |
|
81 | - ( |
|
82 | - 'Authorization: key=' . config('app.gcm_key'), |
|
78 | + $headers = array( |
|
79 | + 'Authorization: key='.config('app.gcm_key'), |
|
83 | 80 | 'Content-Type: application/json' |
84 | 81 | ); |
85 | 82 | $ch = curl_init(); |
@@ -92,7 +89,7 @@ discard block |
||
92 | 89 | $result = curl_exec($ch); |
93 | 90 | curl_close($ch); |
94 | 91 | //echo $result; |
95 | - \Log::info('GCM results: ' . $result); |
|
92 | + \Log::info('GCM results: '.$result); |
|
96 | 93 | } |
97 | 94 | |
98 | 95 | /** |
@@ -101,7 +98,7 @@ discard block |
||
101 | 98 | */ |
102 | 99 | static private function sendEmployeeEmail($email, $meetings) |
103 | 100 | { |
104 | - \Mail::queue('emails.optimise.ok.employee', ['meetings' => $meetings], function ($message) use ($email) { |
|
101 | + \Mail::queue('emails.optimise.ok.employee', [ 'meetings' => $meetings ], function($message) use ($email) { |
|
105 | 102 | $message->from(config('mail.from.address'), config('mail.from.name')); |
106 | 103 | $message->to($email)->subject('Meetings of next week'); |
107 | 104 | }); |
@@ -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 | } |
@@ -63,14 +63,14 @@ discard block |
||
63 | 63 | $this->authorize($meeting); |
64 | 64 | $ret = self::getImg($meeting); |
65 | 65 | if ($ret === false) |
66 | - return \Response::json(['error' => 'The file is not uploaded'], 404); |
|
66 | + return \Response::json([ 'error' => 'The file is not uploaded' ], 404); |
|
67 | 67 | return (new Response($ret, 200)) |
68 | 68 | ->header('Content-Type', 'image/jpeg'); |
69 | 69 | } |
70 | 70 | |
71 | 71 | private static function getImg(Meeting $meeting) |
72 | 72 | { |
73 | - $name = 'meetings/' . $meeting->id; |
|
73 | + $name = 'meetings/'.$meeting->id; |
|
74 | 74 | if (!\Storage::exists($name)) |
75 | 75 | return false; |
76 | 76 | 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 | }); |
@@ -62,8 +64,9 @@ discard block |
||
62 | 64 | $meeting = Group::findOrFail($meetingId); |
63 | 65 | $this->authorize($meeting); |
64 | 66 | $ret = self::getImg($meeting); |
65 | - if ($ret === false) |
|
66 | - return \Response::json(['error' => 'The file is not uploaded'], 404); |
|
67 | + if ($ret === false) { |
|
68 | + return \Response::json(['error' => 'The file is not uploaded'], 404); |
|
69 | + } |
|
67 | 70 | return (new Response($ret, 200)) |
68 | 71 | ->header('Content-Type', 'image/jpeg'); |
69 | 72 | } |
@@ -71,8 +74,9 @@ discard block |
||
71 | 74 | private static function getImg(Meeting $meeting) |
72 | 75 | { |
73 | 76 | $name = 'meetings/' . $meeting->id; |
74 | - if (!\Storage::exists($name)) |
|
75 | - return false; |
|
77 | + if (!\Storage::exists($name)) { |
|
78 | + return false; |
|
79 | + } |
|
76 | 80 | return \Storage::get($name); |
77 | 81 | } |
78 | 82 | } |
@@ -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 | } |