@@ -37,7 +37,7 @@ |
||
37 | 37 | */ |
38 | 38 | public function map(Router $router) |
39 | 39 | { |
40 | - $router->group(['namespace' => $this->namespace], function ($router) { |
|
40 | + $router->group([ 'namespace' => $this->namespace ], function($router) { |
|
41 | 41 | require app_path('Http/routes.php'); |
42 | 42 | }); |
43 | 43 | } |
@@ -51,14 +51,14 @@ |
||
51 | 51 | * |
52 | 52 | * @var array |
53 | 53 | */ |
54 | - protected $fillable = ['name', 'email', 'password']; |
|
54 | + protected $fillable = [ 'name', 'email', 'password' ]; |
|
55 | 55 | |
56 | 56 | /** |
57 | 57 | * The attributes excluded from the model's JSON form. |
58 | 58 | * |
59 | 59 | * @var array |
60 | 60 | */ |
61 | - protected $hidden = ['password', 'remember_token']; |
|
61 | + protected $hidden = [ 'password', 'remember_token' ]; |
|
62 | 62 | |
63 | 63 | public function company() |
64 | 64 | { |
@@ -20,8 +20,8 @@ |
||
20 | 20 | */ |
21 | 21 | public function __construct() |
22 | 22 | { |
23 | - config(['auth.model' => \plunner\Company::class]); |
|
24 | - config(['jwt.user' => \plunner\Company::class]); |
|
23 | + config([ 'auth.model' => \plunner\Company::class ]); |
|
24 | + config([ 'jwt.user' => \plunner\Company::class ]); |
|
25 | 25 | $this->middleware('jwt.authandrefresh:mode-cn'); |
26 | 26 | } |
27 | 27 |
@@ -37,19 +37,19 @@ |
||
37 | 37 | /** |
38 | 38 | * @var array |
39 | 39 | */ |
40 | - protected $touches = ['calendar']; |
|
40 | + protected $touches = [ 'calendar' ]; |
|
41 | 41 | |
42 | 42 | /** |
43 | 43 | * @var array |
44 | 44 | */ |
45 | - protected $fillable = ['url', 'username', 'password', 'calendar_name']; |
|
45 | + protected $fillable = [ 'url', 'username', 'password', 'calendar_name' ]; |
|
46 | 46 | |
47 | 47 | /** |
48 | 48 | * The attributes excluded from the model's JSON form. |
49 | 49 | * |
50 | 50 | * @var array |
51 | 51 | */ |
52 | - protected $hidden = ['password']; |
|
52 | + protected $hidden = [ 'password' ]; |
|
53 | 53 | |
54 | 54 | /** |
55 | 55 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
@@ -37,7 +37,7 @@ |
||
37 | 37 | * |
38 | 38 | * @var array |
39 | 39 | */ |
40 | - protected $fillable = ['name', 'enabled']; |
|
40 | + protected $fillable = [ 'name', 'enabled' ]; |
|
41 | 41 | |
42 | 42 | /** |
43 | 43 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
@@ -46,14 +46,14 @@ |
||
46 | 46 | * |
47 | 47 | * @var array |
48 | 48 | */ |
49 | - protected $fillable = ['title', 'description', 'duration']; |
|
49 | + protected $fillable = [ 'title', 'description', 'duration' ]; |
|
50 | 50 | |
51 | 51 | /** |
52 | 52 | * The attributes excluded from the model's JSON form. |
53 | 53 | * |
54 | 54 | * @var array |
55 | 55 | */ |
56 | - protected $hidden = ['pivot']; |
|
56 | + protected $hidden = [ 'pivot' ]; |
|
57 | 57 | |
58 | 58 | |
59 | 59 | /** |
@@ -39,6 +39,6 @@ |
||
39 | 39 | */ |
40 | 40 | public function broadcastOn() |
41 | 41 | { |
42 | - return []; |
|
42 | + return [ ]; |
|
43 | 43 | } |
44 | 44 | } |
@@ -9,8 +9,8 @@ |
||
9 | 9 | namespace plunner\Console\Commands\Optimise; |
10 | 10 | |
11 | 11 | use Illuminate\Console\Scheduling\Schedule; |
12 | -use plunner\company; |
|
13 | 12 | use plunner\Events\Optimise\ErrorEvent; |
13 | +use plunner\company; |
|
14 | 14 | |
15 | 15 | /** |
16 | 16 | * Class Optimise |
@@ -85,8 +85,8 @@ discard block |
||
85 | 85 | { |
86 | 86 | $this->startTime = clone $startTime; |
87 | 87 | $this->endTime = clone $this->startTime; |
88 | - $this->endTime->add(new \DateInterval('PT' . (($this->max_time_slots + $this->time_slots) * |
|
89 | - config('app.timeslots.duration')) . 'S')); |
|
88 | + $this->endTime->add(new \DateInterval('PT'.(($this->max_time_slots + $this->time_slots) * |
|
89 | + config('app.timeslots.duration')).'S')); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -158,9 +158,9 @@ discard block |
||
158 | 158 | $solver = $this->setData($solver); |
159 | 159 | $solver = $solver->solve(); |
160 | 160 | $this->solver = $solver; |
161 | - }catch(OptimiseException $e) { |
|
161 | + } catch (OptimiseException $e) { |
|
162 | 162 | throw $e; |
163 | - }catch (\Exception $e) { |
|
163 | + } catch (\Exception $e) { |
|
164 | 164 | \Event::fire(new ErrorEvent($this->company, $e->getMessage())); |
165 | 165 | throw new OptimiseException('Optimising error', 0, $e); |
166 | 166 | //TODO catch specif exception |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | { |
205 | 205 | //since we consider busy timeslots, we need to get all users |
206 | 206 | $users = $this->company->employees->pluck('id')->toArray(); |
207 | - if(count($users) == 0) |
|
207 | + if (count($users) == 0) |
|
208 | 208 | throw ((new OptimiseException("No users for this company"))->withEmpty(true)); |
209 | 209 | return $solver->setUsers($users); |
210 | 210 | } |
@@ -220,9 +220,9 @@ discard block |
||
220 | 220 | * @var $meetings \Illuminate\Support\Collection |
221 | 221 | */ |
222 | 222 | $meetings = collect($this->company->getMeetingsTimeSlots($this->startTime, $this->endTime)); |
223 | - if($meetings->count() == 0) |
|
223 | + if ($meetings->count() == 0) |
|
224 | 224 | throw ((new OptimiseException("No meetings for this week"))->withEmpty(true)); |
225 | - $timeslots = $meetings->groupBy('id')->map(function ($item) { //convert timeslots |
|
225 | + $timeslots = $meetings->groupBy('id')->map(function($item) { //convert timeslots |
|
226 | 226 | return $this->durationConverter($this->timeSlotsConverter($item)); |
227 | 227 | }); |
228 | 228 | return $solver->setMeetings($timeslots->keys()->toArray()) |
@@ -236,8 +236,8 @@ discard block |
||
236 | 236 | */ |
237 | 237 | private function durationConverter($item) |
238 | 238 | { |
239 | - return $item->each(function ($item2) { |
|
240 | - $item2->duration = $this->convertDuration((int)$item2->duration); |
|
239 | + return $item->each(function($item2) { |
|
240 | + $item2->duration = $this->convertDuration((int) $item2->duration); |
|
241 | 241 | return $item2; |
242 | 242 | //TODO try catch |
243 | 243 | }); |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | */ |
250 | 250 | static private function convertDuration($duration) |
251 | 251 | { |
252 | - return (int)ceil($duration / config('app.timeslots.duration')); |
|
252 | + return (int) ceil($duration / config('app.timeslots.duration')); |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | /** |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | */ |
259 | 259 | private function timeSlotsConverter($item) |
260 | 260 | { |
261 | - return $item->each(function ($item2) { |
|
261 | + return $item->each(function($item2) { |
|
262 | 262 | $item2->time_start = $this->toTimeSlot($item2->time_start); |
263 | 263 | $item2->time_end = $this->toTimeSlot($item2->time_end); |
264 | 264 | return $item2; |
@@ -276,13 +276,13 @@ discard block |
||
276 | 276 | $dateTime = new \DateTime($time); |
277 | 277 | $diff = $dateTime->diff($this->startTime); |
278 | 278 | $diff = explode(':', $diff->format('%R:%d:%h:%i:%s')); |
279 | - $diff = $diff[1] * 86400 + $diff[2] * 3600 + $diff[3] * 60 + $diff[4]; |
|
279 | + $diff = $diff[ 1 ] * 86400 + $diff[ 2 ] * 3600 + $diff[ 3 ] * 60 + $diff[ 4 ]; |
|
280 | 280 | //if($diff[0] != '-' && $diff != 0) |
281 | 281 | // throw new OptimiseException('timeslot time <= startTime'); |
282 | 282 | //TODO fix check |
283 | 283 | //TODO check if diff makes sense |
284 | 284 | //TODO check upper limit |
285 | - return (int)(round($diff / config('app.timeslots.duration')) + 1); //TODO can round cause overlaps? |
|
285 | + return (int) (round($diff / config('app.timeslots.duration')) + 1); //TODO can round cause overlaps? |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | /** |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | */ |
293 | 293 | static private function getAvailabilityArray(\Illuminate\Support\Collection $timeSlots, $timeslotsN, $free = true) |
294 | 294 | { |
295 | - $ret = []; |
|
295 | + $ret = [ ]; |
|
296 | 296 | foreach ($timeSlots as $id => $timeSlots2) { |
297 | 297 | $ret = self::fillTimeSlots($ret, $id, $timeSlots2, $free ? '1' : '0'); |
298 | 298 | $ret = self::fillRow($ret, $id, $timeslotsN, $free ? '0' : '1'); |
@@ -311,9 +311,9 @@ discard block |
||
311 | 311 | static private function fillTimeSlots(array $array, $id, \Illuminate\Support\Collection $timeSlots, $fill = '0') |
312 | 312 | { |
313 | 313 | foreach ($timeSlots as $timeSlot) { |
314 | - if (!isset($array[$id])) |
|
315 | - $array[$id] = []; |
|
316 | - $array[$id] = self::arrayPadInterval($array[$id], $timeSlot->time_start, $timeSlot->time_end, $fill); |
|
314 | + if (!isset($array[ $id ])) |
|
315 | + $array[ $id ] = [ ]; |
|
316 | + $array[ $id ] = self::arrayPadInterval($array[ $id ], $timeSlot->time_start, $timeSlot->time_end, $fill); |
|
317 | 317 | } |
318 | 318 | return $array; |
319 | 319 | } |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | static private function arrayPadInterval(array $array, $from, $to, $pad = '0') |
329 | 329 | { |
330 | 330 | for ($i = $from; $i < $to; $i++) |
331 | - $array[$i] = $pad; |
|
331 | + $array[ $i ] = $pad; |
|
332 | 332 | return $array; |
333 | 333 | } |
334 | 334 | |
@@ -341,8 +341,8 @@ discard block |
||
341 | 341 | static private function fillRow(array $array, $id, $until, $fill = '0') |
342 | 342 | { |
343 | 343 | for ($i = 1; $i <= $until; $i++) { |
344 | - if (!isset($array[$id][$i])) |
|
345 | - $array[$id][$i] = $fill; |
|
344 | + if (!isset($array[ $id ][ $i ])) |
|
345 | + $array[ $id ][ $i ] = $fill; |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | return $array; |
@@ -359,9 +359,9 @@ discard block |
||
359 | 359 | * @var $users \Illuminate\Support\Collection |
360 | 360 | */ |
361 | 361 | $users = collect($this->company->getEmployeesTimeSlots($this->startTime, $this->endTime)); |
362 | - if($users->count() == 0) |
|
362 | + if ($users->count() == 0) |
|
363 | 363 | throw ((new OptimiseException("No users for this company"))->withEmpty(true)); |
364 | - $timeslots = $users->groupBy('id')->map(function ($item) { //convert timeslots |
|
364 | + $timeslots = $users->groupBy('id')->map(function($item) { //convert timeslots |
|
365 | 365 | return $this->timeSlotsConverter($item); |
366 | 366 | }); |
367 | 367 | return $solver->setUsersAvailability(self::getAvailabilityArray($timeslots, $this->time_slots, false)); |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | * @var $usersMeetings \Illuminate\Support\Collection |
381 | 381 | */ |
382 | 382 | $usersMeetings = collect($this->company->getUsersMeetings($users, $meetings))->groupBy('employee_id'); |
383 | - if($usersMeetings->count() == 0) |
|
383 | + if ($usersMeetings->count() == 0) |
|
384 | 384 | throw ((new OptimiseException("No users for any meeting"))->withEmpty(true)); |
385 | 385 | |
386 | 386 | return $solver->setUsersMeetings(self::getUsersMeetingsArray($users, $meetings, $usersMeetings)); |
@@ -394,14 +394,14 @@ discard block |
||
394 | 394 | */ |
395 | 395 | static private function getUsersMeetingsArray($users, $meetings, \Illuminate\Support\Collection $usersMeetings) |
396 | 396 | { |
397 | - $ret = []; |
|
397 | + $ret = [ ]; |
|
398 | 398 | foreach ($users as $user) { |
399 | 399 | $usersMeetingsTmp = $usersMeetings->get($user); |
400 | 400 | foreach ($meetings as $meeting) { |
401 | 401 | if ($usersMeetingsTmp->contains('meeting_id', $meeting)) { |
402 | - $ret[$user][$meeting] = 1; |
|
402 | + $ret[ $user ][ $meeting ] = 1; |
|
403 | 403 | } else { |
404 | - $ret[$user][$meeting] = 0; |
|
404 | + $ret[ $user ][ $meeting ] = 0; |
|
405 | 405 | } |
406 | 406 | } |
407 | 407 | } |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | { |
443 | 443 | $meetings = $solver->getYResults(); |
444 | 444 | foreach ($meetings as $id => $meeting) { |
445 | - $meetingO = \plunner\Meeting::findOrFail($id);//TODO catch error |
|
445 | + $meetingO = \plunner\Meeting::findOrFail($id); //TODO catch error |
|
446 | 446 | $meetingO->start_time = $this->toDateTime(array_search('1', $meeting)); |
447 | 447 | $meetingO->save(); |
448 | 448 | } |
@@ -455,7 +455,7 @@ discard block |
||
455 | 455 | private function toDateTime($timeslot) |
456 | 456 | { |
457 | 457 | $ret = clone $this->startTime; |
458 | - return $ret->add(new \DateInterval('PT' . (($timeslot - 1) * config('app.timeslots.duration')) . 'S')); |
|
458 | + return $ret->add(new \DateInterval('PT'.(($timeslot - 1) * config('app.timeslots.duration')).'S')); |
|
459 | 459 | } |
460 | 460 | |
461 | 461 | /** |
@@ -467,7 +467,7 @@ discard block |
||
467 | 467 | foreach ($employeesMeetings as $eId => $employeeMeetings) { |
468 | 468 | $employee = \plunner\Employee::findOrFail($eId); |
469 | 469 | $employeeMeetings = collect($employeeMeetings); |
470 | - $employeeMeetings = $employeeMeetings->filter(function ($item) { |
|
470 | + $employeeMeetings = $employeeMeetings->filter(function($item) { |
|
471 | 471 | return $item == 1; |
472 | 472 | }); |
473 | 473 | $employee->meetings()->attach($employeeMeetings->keys()->toArray()); |
@@ -39,6 +39,6 @@ |
||
39 | 39 | */ |
40 | 40 | public function broadcastOn() |
41 | 41 | { |
42 | - return []; |
|
42 | + return [ ]; |
|
43 | 43 | } |
44 | 44 | } |