@@ -39,10 +39,11 @@ |
||
| 39 | 39 | { |
| 40 | 40 | // |
| 41 | 41 | $companyId = $this->argument('companyId'); |
| 42 | - if (is_numeric($companyId)) |
|
| 43 | - print_r(Company::with(self::withFilter())->findOrFail($companyId)->toArray()); |
|
| 44 | - else |
|
| 45 | - print_r(Company::with(self::withFilter())->select('id')->get()->toArray()); |
|
| 42 | + if (is_numeric($companyId)) { |
|
| 43 | + print_r(Company::with(self::withFilter())->findOrFail($companyId)->toArray()); |
|
| 44 | + } else { |
|
| 45 | + print_r(Company::with(self::withFilter())->select('id')->get()->toArray()); |
|
| 46 | + } |
|
| 46 | 47 | } |
| 47 | 48 | |
| 48 | 49 | private static function withFilter() |
@@ -32,9 +32,11 @@ discard block |
||
| 32 | 32 | $group = Group::findOrFail($groupId); |
| 33 | 33 | $this->authorize($group); |
| 34 | 34 | $meetings = $group->meetings(); |
| 35 | - if ($request->query('current')) |
|
| 36 | - $meetings->where(function ($query) { //parenthesis for conditions ...(C1 OR C2)... |
|
| 37 | - $query->where('start_time', '=', NULL);//to be planned |
|
| 35 | + if ($request->query('current')) { |
|
| 36 | + $meetings->where(function ($query) { //parenthesis for conditions ...(C1 OR C2)... |
|
| 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 | }); |
@@ -115,8 +117,9 @@ discard block |
||
| 115 | 117 | $meeting = Group::findOrFail($meetingId); |
| 116 | 118 | $this->authorize($meeting); |
| 117 | 119 | $ret = self::getImg($meeting); |
| 118 | - if ($ret === false) |
|
| 119 | - return \Response::json(['error' => 'The file is not uploaded'], 404); |
|
| 120 | + if ($ret === false) { |
|
| 121 | + return \Response::json(['error' => 'The file is not uploaded'], 404); |
|
| 122 | + } |
|
| 120 | 123 | return (new Response($ret, 200)) |
| 121 | 124 | ->header('Content-Type', 'image/jpeg'); |
| 122 | 125 | } |
@@ -124,8 +127,9 @@ discard block |
||
| 124 | 127 | private static function getImg(Meeting $meeting) |
| 125 | 128 | { |
| 126 | 129 | $name = 'meetings/' . $meeting->id; |
| 127 | - if (!\Storage::exists($name)) |
|
| 128 | - return false; |
|
| 130 | + if (!\Storage::exists($name)) { |
|
| 131 | + return false; |
|
| 132 | + } |
|
| 129 | 133 | return \Storage::get($name); |
| 130 | 134 | } |
| 131 | 135 | |
@@ -145,8 +149,9 @@ discard block |
||
| 145 | 149 | $this->authorize($meeting); |
| 146 | 150 | $input = $request->all(); |
| 147 | 151 | //the planner cannot modify the duration of a planed meeting |
| 148 | - if ($meeting->start_time != NULL && $meeting->duration != $input['duration']) |
|
| 149 | - return Response::json(['error' => 'the meeting is already planned, you cannot change the duration'], 422); |
|
| 152 | + if ($meeting->start_time != NULL && $meeting->duration != $input['duration']) { |
|
| 153 | + return Response::json(['error' => 'the meeting is already planned, you cannot change the duration'], 422); |
|
| 154 | + } |
|
| 150 | 155 | $meeting->update($input); |
| 151 | 156 | return $meeting; |
| 152 | 157 | } |
@@ -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 | } |