@@ -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 |
@@ -18,36 +18,36 @@ discard block |
||
| 18 | 18 | /** |
| 19 | 19 | * Companies |
| 20 | 20 | */ |
| 21 | -Route::group(['namespace' => 'Companies', 'prefix' => 'companies'], function() { |
|
| 21 | +Route::group([ 'namespace' => 'Companies', 'prefix' => 'companies' ], function() { |
|
| 22 | 22 | |
| 23 | 23 | //\Auth |
| 24 | 24 | |
| 25 | - Route::group(['namespace' => 'Auth'], function() { |
|
| 26 | - Route::group(['prefix' => 'auth'], function () { |
|
| 25 | + Route::group([ 'namespace' => 'Auth' ], function() { |
|
| 26 | + Route::group([ 'prefix' => 'auth' ], function() { |
|
| 27 | 27 | // Authentication routes... |
| 28 | - Route::post('login', ['as' => 'companies.auth.login','uses'=>'AuthController@postLogin']); |
|
| 28 | + Route::post('login', [ 'as' => 'companies.auth.login', 'uses'=>'AuthController@postLogin' ]); |
|
| 29 | 29 | |
| 30 | 30 | // Registration routes... |
| 31 | - Route::post('register', ['as' => 'companies.auth.register', 'uses'=>'AuthController@postRegister']); |
|
| 31 | + Route::post('register', [ 'as' => 'companies.auth.register', 'uses'=>'AuthController@postRegister' ]); |
|
| 32 | 32 | |
| 33 | 33 | }); |
| 34 | 34 | |
| 35 | - Route::group(['prefix' => 'password'], function () { |
|
| 35 | + Route::group([ 'prefix' => 'password' ], function() { |
|
| 36 | 36 | // Password reset link request routes... |
| 37 | - Route::post('email', ['as' => 'companies.auth.email', 'uses'=>'PasswordController@postEmail']); |
|
| 37 | + Route::post('email', [ 'as' => 'companies.auth.email', 'uses'=>'PasswordController@postEmail' ]); |
|
| 38 | 38 | |
| 39 | 39 | // Password reset routes... |
| 40 | - Route::post('reset', ['as' => 'companies.auth.reset', 'uses'=>'PasswordController@postReset']); |
|
| 40 | + Route::post('reset', [ 'as' => 'companies.auth.reset', 'uses'=>'PasswordController@postReset' ]); |
|
| 41 | 41 | }); |
| 42 | 42 | }); |
| 43 | 43 | |
| 44 | - Route::group(['namespace' => 'Employees'], function() { |
|
| 45 | - Route::resource('employees', 'EmployeesController', ['except' => ['create', 'edit']]); |
|
| 44 | + Route::group([ 'namespace' => 'Employees' ], function() { |
|
| 45 | + Route::resource('employees', 'EmployeesController', [ 'except' => [ 'create', 'edit' ] ]); |
|
| 46 | 46 | }); |
| 47 | 47 | |
| 48 | - Route::group(['namespace' => 'Groups'], function() { |
|
| 49 | - Route::resource('groups', 'GroupsController', ['except' => ['create', 'edit']]); |
|
| 50 | - Route::resource('groups.employees', 'EmployeesController', ['only' => ['store', 'index', 'destroy']]); |
|
| 48 | + Route::group([ 'namespace' => 'Groups' ], function() { |
|
| 49 | + Route::resource('groups', 'GroupsController', [ 'except' => [ 'create', 'edit' ] ]); |
|
| 50 | + Route::resource('groups.employees', 'EmployeesController', [ 'only' => [ 'store', 'index', 'destroy' ] ]); |
|
| 51 | 51 | }); |
| 52 | 52 | }); |
| 53 | 53 | |
@@ -55,39 +55,39 @@ discard block |
||
| 55 | 55 | /** |
| 56 | 56 | * Employees |
| 57 | 57 | */ |
| 58 | -Route::group(['namespace' => 'Employees', 'prefix' => 'employees'], function() { |
|
| 58 | +Route::group([ 'namespace' => 'Employees', 'prefix' => 'employees' ], function() { |
|
| 59 | 59 | |
| 60 | 60 | //\Auth |
| 61 | - Route::group(['namespace' => 'Auth'], function() { |
|
| 62 | - Route::group(['prefix' => 'auth'], function () { |
|
| 61 | + Route::group([ 'namespace' => 'Auth' ], function() { |
|
| 62 | + Route::group([ 'prefix' => 'auth' ], function() { |
|
| 63 | 63 | // Authentication routes... |
| 64 | - Route::post('login', ['as' => 'companies.auth.login', 'uses'=>'AuthController@postLogin']); |
|
| 64 | + Route::post('login', [ 'as' => 'companies.auth.login', 'uses'=>'AuthController@postLogin' ]); |
|
| 65 | 65 | |
| 66 | 66 | // Registration routes... |
| 67 | 67 | //Route::post('register', ['as' => 'companies.auth.register', 'uses'=>'AuthController@postRegister']); //the registration is managed by the company |
| 68 | 68 | |
| 69 | 69 | }); |
| 70 | 70 | |
| 71 | - Route::group(['prefix' => 'password'], function () { |
|
| 71 | + Route::group([ 'prefix' => 'password' ], function() { |
|
| 72 | 72 | // Password reset link request routes... |
| 73 | - Route::post('email', ['as' => 'companies.auth.email', 'uses'=>'PasswordController@postEmail']); |
|
| 73 | + Route::post('email', [ 'as' => 'companies.auth.email', 'uses'=>'PasswordController@postEmail' ]); |
|
| 74 | 74 | |
| 75 | 75 | // Password reset routes... |
| 76 | - Route::post('reset', ['as' => 'companies.auth.reset', 'uses'=>'PasswordController@postReset']); |
|
| 76 | + Route::post('reset', [ 'as' => 'companies.auth.reset', 'uses'=>'PasswordController@postReset' ]); |
|
| 77 | 77 | }); |
| 78 | 78 | }); |
| 79 | 79 | |
| 80 | - Route::group(['namespace' => 'Calendars'], function() { |
|
| 81 | - Route::resource('calendars', 'CalendarsController', ['except' => ['create', 'edit']]); |
|
| 82 | - Route::post('calendars/caldav', ['as' => 'employees.calendars.caldav','uses'=>'CalendarsController@storeCaldav']); |
|
| 83 | - Route::post('calendars/calendars', ['as' => 'employees.calendars.calendars','uses'=>'CalendarsController@getCalendars']); //TODO it's correct post? or not |
|
| 80 | + Route::group([ 'namespace' => 'Calendars' ], function() { |
|
| 81 | + Route::resource('calendars', 'CalendarsController', [ 'except' => [ 'create', 'edit' ] ]); |
|
| 82 | + Route::post('calendars/caldav', [ 'as' => 'employees.calendars.caldav', 'uses'=>'CalendarsController@storeCaldav' ]); |
|
| 83 | + Route::post('calendars/calendars', [ 'as' => 'employees.calendars.calendars', 'uses'=>'CalendarsController@getCalendars' ]); //TODO it's correct post? or not |
|
| 84 | 84 | }); |
| 85 | 85 | |
| 86 | - Route::group(['namespace' => 'Planners', 'prefix' => 'planners'], function() { |
|
| 87 | - Route::resource('groups', 'GroupsController', ['only' => ['index', 'show']]); |
|
| 86 | + Route::group([ 'namespace' => 'Planners', 'prefix' => 'planners' ], function() { |
|
| 87 | + Route::resource('groups', 'GroupsController', [ 'only' => [ 'index', 'show' ] ]); |
|
| 88 | 88 | }); |
| 89 | 89 | |
| 90 | - Route::group(['namespace' => 'Groups'], function() { |
|
| 91 | - Route::resource('groups', 'GroupsController', ['only' => ['index', 'show']]); |
|
| 90 | + Route::group([ 'namespace' => 'Groups' ], function() { |
|
| 91 | + Route::resource('groups', 'GroupsController', [ 'only' => [ 'index', 'show' ] ]); |
|
| 92 | 92 | }); |
| 93 | 93 | }); |
| 94 | 94 | \ No newline at end of file |
@@ -11,7 +11,7 @@ |
||
| 11 | 11 | * |
| 12 | 12 | * @var array |
| 13 | 13 | */ |
| 14 | - protected $fillable = ['time_start', 'time_end']; |
|
| 14 | + protected $fillable = [ 'time_start', 'time_end' ]; |
|
| 15 | 15 | |
| 16 | 16 | public function employees() |
| 17 | 17 | { |
@@ -17,8 +17,8 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | public function __construct() |
| 19 | 19 | { |
| 20 | - config(['auth.model' => \plunner\Employee::class]); |
|
| 21 | - config(['jwt.user' => \plunner\Employee::class]); |
|
| 20 | + config([ 'auth.model' => \plunner\Employee::class ]); |
|
| 21 | + config([ 'jwt.user' => \plunner\Employee::class ]); |
|
| 22 | 22 | $this->middleware('jwt.authandrefresh:mode-en'); |
| 23 | 23 | } |
| 24 | 24 | |
@@ -66,8 +66,8 @@ discard block |
||
| 66 | 66 | $employee = \Auth::user(); |
| 67 | 67 | $input = $request->all(); |
| 68 | 68 | $calendar = $employee->calendars()->create($input); |
| 69 | - if(isset($input['password'])) |
|
| 70 | - $input['password'] = \Crypt::encrypt($input['password']); |
|
| 69 | + if (isset($input[ 'password' ])) |
|
| 70 | + $input[ 'password' ] = \Crypt::encrypt($input[ 'password' ]); |
|
| 71 | 71 | $calendar->caldav()->create($input); |
| 72 | 72 | //TODO test |
| 73 | 73 | //TODO validator |
@@ -104,17 +104,17 @@ discard block |
||
| 104 | 104 | $this->authorize($calendar); |
| 105 | 105 | $input = $request->all(); |
| 106 | 106 | $caldav = $calendar->caldav; |
| 107 | - if($caldav){ |
|
| 107 | + if ($caldav) { |
|
| 108 | 108 | $this->validateCaldav($request); |
| 109 | 109 | } |
| 110 | - if(isset($input['password'])) |
|
| 111 | - $input['password'] = \Crypt::encrypt($input['password']); |
|
| 110 | + if (isset($input[ 'password' ])) |
|
| 111 | + $input[ 'password' ] = \Crypt::encrypt($input[ 'password' ]); |
|
| 112 | 112 | $calendar->update($input); |
| 113 | 113 | //TODO test |
| 114 | 114 | //TODO validator |
| 115 | 115 | //TODO check if caldav exists? |
| 116 | 116 | |
| 117 | - if($caldav) |
|
| 117 | + if ($caldav) |
|
| 118 | 118 | $caldav->update($input); |
| 119 | 119 | return $calendar; |
| 120 | 120 | } |
@@ -148,9 +148,9 @@ discard block |
||
| 148 | 148 | $caldavClient->connect($request->input('url'), $request->input('username'), $request->input('password')); |
| 149 | 149 | $calendars = $caldavClient->findCalendars(); |
| 150 | 150 | return array_keys($calendars); |
| 151 | - }catch (\it\thecsea\caldav_client_adapter\CaldavException $e) |
|
| 151 | + } catch (\it\thecsea\caldav_client_adapter\CaldavException $e) |
|
| 152 | 152 | { |
| 153 | - return Response::json(['error' => $e->getMessage()],422); |
|
| 153 | + return Response::json([ 'error' => $e->getMessage() ], 422); |
|
| 154 | 154 | } |
| 155 | 155 | } |
| 156 | 156 | |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | $this->validate($request, [ |
| 163 | 163 | 'url' => 'required|max:255', |
| 164 | 164 | 'username' => 'required|max:255', |
| 165 | - 'password' => ((\Route::current()->getName() == 'companies.calendars.caldav')?'required':''), |
|
| 165 | + 'password' => ((\Route::current()->getName() == 'companies.calendars.caldav') ? 'required' : ''), |
|
| 166 | 166 | 'calendar_name' => 'required|max:255', |
| 167 | 167 | ]); |
| 168 | 168 | } |
@@ -66,8 +66,9 @@ discard block |
||
| 66 | 66 | $employee = \Auth::user(); |
| 67 | 67 | $input = $request->all(); |
| 68 | 68 | $calendar = $employee->calendars()->create($input); |
| 69 | - if(isset($input['password'])) |
|
| 70 | - $input['password'] = \Crypt::encrypt($input['password']); |
|
| 69 | + if(isset($input['password'])) { |
|
| 70 | + $input['password'] = \Crypt::encrypt($input['password']); |
|
| 71 | + } |
|
| 71 | 72 | $calendar->caldav()->create($input); |
| 72 | 73 | //TODO test |
| 73 | 74 | //TODO validator |
@@ -107,15 +108,17 @@ discard block |
||
| 107 | 108 | if($caldav){ |
| 108 | 109 | $this->validateCaldav($request); |
| 109 | 110 | } |
| 110 | - if(isset($input['password'])) |
|
| 111 | - $input['password'] = \Crypt::encrypt($input['password']); |
|
| 111 | + if(isset($input['password'])) { |
|
| 112 | + $input['password'] = \Crypt::encrypt($input['password']); |
|
| 113 | + } |
|
| 112 | 114 | $calendar->update($input); |
| 113 | 115 | //TODO test |
| 114 | 116 | //TODO validator |
| 115 | 117 | //TODO check if caldav exists? |
| 116 | 118 | |
| 117 | - if($caldav) |
|
| 118 | - $caldav->update($input); |
|
| 119 | + if($caldav) { |
|
| 120 | + $caldav->update($input); |
|
| 121 | + } |
|
| 119 | 122 | return $calendar; |
| 120 | 123 | } |
| 121 | 124 | |
@@ -148,7 +151,7 @@ discard block |
||
| 148 | 151 | $caldavClient->connect($request->input('url'), $request->input('username'), $request->input('password')); |
| 149 | 152 | $calendars = $caldavClient->findCalendars(); |
| 150 | 153 | return array_keys($calendars); |
| 151 | - }catch (\it\thecsea\caldav_client_adapter\CaldavException $e) |
|
| 154 | + } catch (\it\thecsea\caldav_client_adapter\CaldavException $e) |
|
| 152 | 155 | { |
| 153 | 156 | return Response::json(['error' => $e->getMessage()],422); |
| 154 | 157 | } |
@@ -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 | /** |
@@ -3,8 +3,6 @@ |
||
| 3 | 3 | namespace plunner\Listeners; |
| 4 | 4 | |
| 5 | 5 | use plunner\Events\CaldavErrorEvent; |
| 6 | -use Illuminate\Queue\InteractsWithQueue; |
|
| 7 | -use Illuminate\Contracts\Queue\ShouldQueue; |
|
| 8 | 6 | |
| 9 | 7 | class CaldavErrorListener |
| 10 | 8 | { |
@@ -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 |
@@ -1,10 +1,10 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Created by PhpStorm. |
|
| 4 | - * User: claudio |
|
| 5 | - * Date: 12/12/15 |
|
| 6 | - * Time: 15.41 |
|
| 7 | - */ |
|
| 3 | + * Created by PhpStorm. |
|
| 4 | + * User: claudio |
|
| 5 | + * Date: 12/12/15 |
|
| 6 | + * Time: 15.41 |
|
| 7 | + */ |
|
| 8 | 8 | |
| 9 | 9 | namespace plunner\Console\Commands\Optimise; |
| 10 | 10 | |
@@ -45,8 +45,8 @@ discard block |
||
| 45 | 45 | private $company; |
| 46 | 46 | |
| 47 | 47 | /** |
| 48 | - * @var Schedule laravel schedule object needed to perform command in background |
|
| 49 | - */ |
|
| 48 | + * @var Schedule laravel schedule object needed to perform command in background |
|
| 49 | + */ |
|
| 50 | 50 | private $schedule; |
| 51 | 51 | |
| 52 | 52 | /** |
@@ -413,7 +413,7 @@ discard block |
||
| 413 | 413 | $diff = explode(':',$diff->format('%R:%d:%h:%i:%s')); |
| 414 | 414 | $diff = $diff[1]*86400 + $diff[2]*3600 + $diff[3]*60 + $diff[4]; |
| 415 | 415 | //if($diff[0] != '-' && $diff != 0) |
| 416 | - // throw new OptimiseException('timeslot time <= startTime'); |
|
| 416 | + // throw new OptimiseException('timeslot time <= startTime'); |
|
| 417 | 417 | //TODO fix check |
| 418 | 418 | //TODO check if diff makes sense |
| 419 | 419 | //TODO check upper limit |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | $solver = $this->setData($solver); |
| 157 | 157 | $solver = $solver->solve(); |
| 158 | 158 | $this->solver = $solver; |
| 159 | - }catch(\Exception $e) |
|
| 159 | + } catch(\Exception $e) |
|
| 160 | 160 | { |
| 161 | 161 | \Event::fire(new ErrorEvent($this->company, $e->getMessage())); |
| 162 | 162 | throw new OptimiseException('Optimising error', 0, $e); |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | try { |
| 181 | 181 | $this->saveMeetings($this->solver); |
| 182 | 182 | $this->saveEmployeesMeetings($this->solver); |
| 183 | - }catch(\Exception $e) |
|
| 183 | + } catch(\Exception $e) |
|
| 184 | 184 | { |
| 185 | 185 | \Event::fire(new ErrorEvent($this->company, $e->getMessage())); |
| 186 | 186 | throw new OptimiseException('Optimising error', 0, $e); |
@@ -327,7 +327,7 @@ discard block |
||
| 327 | 327 | foreach($meetings as $meeting){ |
| 328 | 328 | if($usersMeetingsTmp->contains('meeting_id', $meeting)){ |
| 329 | 329 | $ret[$user][$meeting] = 1; |
| 330 | - }else{ |
|
| 330 | + } else{ |
|
| 331 | 331 | $ret[$user][$meeting] = 0; |
| 332 | 332 | } |
| 333 | 333 | } |
@@ -373,8 +373,9 @@ discard block |
||
| 373 | 373 | static private function fillTimeSlots(array $array, $id, \Illuminate\Support\Collection $timeSlots, $fill = '0') |
| 374 | 374 | { |
| 375 | 375 | foreach($timeSlots as $timeSlot) { |
| 376 | - if(!isset($array[$id])) |
|
| 377 | - $array[$id] = []; |
|
| 376 | + if(!isset($array[$id])) { |
|
| 377 | + $array[$id] = []; |
|
| 378 | + } |
|
| 378 | 379 | $array[$id] = self::arrayPadInterval($array[$id], $timeSlot->time_start, $timeSlot->time_end, $fill); |
| 379 | 380 | } |
| 380 | 381 | return $array; |
@@ -389,8 +390,9 @@ discard block |
||
| 389 | 390 | static private function fillRow(array $array, $id, $until, $fill = '0') |
| 390 | 391 | { |
| 391 | 392 | for($i = 1; $i <= $until; $i++){ |
| 392 | - if(!isset($array[$id][$i])) |
|
| 393 | - $array[$id][$i] = $fill; |
|
| 393 | + if(!isset($array[$id][$i])) { |
|
| 394 | + $array[$id][$i] = $fill; |
|
| 395 | + } |
|
| 394 | 396 | } |
| 395 | 397 | |
| 396 | 398 | return $array; |
@@ -405,8 +407,9 @@ discard block |
||
| 405 | 407 | */ |
| 406 | 408 | static private function arrayPadInterval(array $array, $from, $to, $pad = '0') |
| 407 | 409 | { |
| 408 | - for($i = $from; $i<$to; $i++) |
|
| 409 | - $array[$i] = $pad; |
|
| 410 | + for($i = $from; $i<$to; $i++) { |
|
| 411 | + $array[$i] = $pad; |
|
| 412 | + } |
|
| 410 | 413 | return $array; |
| 411 | 414 | } |
| 412 | 415 | |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | //TODo max timeslots can be an environment var |
| 25 | 25 | const TIME_SLOT_DURATION = 900; //seconds -> 15 minutes |
| 26 | 26 | const DEFAULT_MAX_TIME_SLOTS = 20; //max duration of a meeting in term of timeslots //20 |
| 27 | - const DEFAULT_TIME_SLOTS = 672; //total amount of timeslots that must be optimised -> one week 4*24*7 = 672 |
|
| 27 | + const DEFAULT_TIME_SLOTS = 672; //total amount of timeslots that must be optimised -> one week 4*24*7 = 672 |
|
| 28 | 28 | |
| 29 | 29 | private $max_time_slots = self::DEFAULT_MAX_TIME_SLOTS; |
| 30 | 30 | private $time_slots = self::DEFAULT_TIME_SLOTS; |
@@ -85,7 +85,7 @@ 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)*self::TIME_SLOT_DURATION).'S')); |
|
| 88 | + $this->endTime->add(new \DateInterval('PT'.(($this->max_time_slots + $this->time_slots) * self::TIME_SLOT_DURATION).'S')); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | /** |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | $solver = $this->setData($solver); |
| 157 | 157 | $solver = $solver->solve(); |
| 158 | 158 | $this->solver = $solver; |
| 159 | - }catch(\Exception $e) |
|
| 159 | + } catch (\Exception $e) |
|
| 160 | 160 | { |
| 161 | 161 | \Event::fire(new ErrorEvent($this->company, $e->getMessage())); |
| 162 | 162 | throw new OptimiseException('Optimising error', 0, $e); |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | */ |
| 171 | 171 | public function save() |
| 172 | 172 | { |
| 173 | - if(!($this->solver instanceof Solver)) { |
|
| 173 | + if (!($this->solver instanceof Solver)) { |
|
| 174 | 174 | \Event::fire(new ErrorEvent($this->company, 'solver is not an instace of Solver')); |
| 175 | 175 | throw new OptimiseException('solver is not an instance of Solver'); |
| 176 | 176 | return; |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | try { |
| 181 | 181 | $this->saveMeetings($this->solver); |
| 182 | 182 | $this->saveEmployeesMeetings($this->solver); |
| 183 | - }catch(\Exception $e) |
|
| 183 | + } catch (\Exception $e) |
|
| 184 | 184 | { |
| 185 | 185 | \Event::fire(new ErrorEvent($this->company, $e->getMessage())); |
| 186 | 186 | throw new OptimiseException('Optimising error', 0, $e); |
@@ -197,8 +197,8 @@ discard block |
||
| 197 | 197 | private function saveMeetings(Solver $solver) |
| 198 | 198 | { |
| 199 | 199 | $meetings = $solver->getYResults(); |
| 200 | - foreach($meetings as $id=>$meeting){ |
|
| 201 | - $meetingO = \plunner\Meeting::findOrFail($id);//TODO catch error |
|
| 200 | + foreach ($meetings as $id=>$meeting) { |
|
| 201 | + $meetingO = \plunner\Meeting::findOrFail($id); //TODO catch error |
|
| 202 | 202 | $meetingO->start_time = $this->toDateTime(array_search('1', $meeting)); |
| 203 | 203 | $meetingO->save(); |
| 204 | 204 | } |
@@ -210,11 +210,11 @@ discard block |
||
| 210 | 210 | private function saveEmployeesMeetings(Solver $solver) |
| 211 | 211 | { |
| 212 | 212 | $employeesMeetings = $solver->getXResults(); |
| 213 | - foreach($employeesMeetings as $eId =>$employeeMeetings) |
|
| 213 | + foreach ($employeesMeetings as $eId =>$employeeMeetings) |
|
| 214 | 214 | { |
| 215 | 215 | $employee = \plunner\Employee::findOrFail($eId); |
| 216 | 216 | $employeeMeetings = collect($employeeMeetings); |
| 217 | - $employeeMeetings = $employeeMeetings->filter(function ($item) { |
|
| 217 | + $employeeMeetings = $employeeMeetings->filter(function($item) { |
|
| 218 | 218 | return $item == 1; |
| 219 | 219 | }); |
| 220 | 220 | $employee->meetings()->attach($employeeMeetings->keys()->toArray()); |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | return $this->durationConverter($this->timeSlotsConverter($item)); |
| 273 | 273 | }); |
| 274 | 274 | return $solver->setMeetings($timeslots->keys()->toArray()) |
| 275 | - ->setMeetingsDuration($meetings->pluck('duration','id')->toArray()) |
|
| 275 | + ->setMeetingsDuration($meetings->pluck('duration', 'id')->toArray()) |
|
| 276 | 276 | ->setMeetingsAvailability(self::getAvailabilityArray($timeslots, $this->time_slots)); |
| 277 | 277 | } |
| 278 | 278 | |
@@ -318,15 +318,15 @@ discard block |
||
| 318 | 318 | */ |
| 319 | 319 | static private function getUsersMeetingsArray($users, $meetings, \Illuminate\Support\Collection $usersMeetings) |
| 320 | 320 | { |
| 321 | - $ret = []; |
|
| 322 | - foreach($users as $user) |
|
| 321 | + $ret = [ ]; |
|
| 322 | + foreach ($users as $user) |
|
| 323 | 323 | { |
| 324 | 324 | $usersMeetingsTmp = $usersMeetings->get($user); |
| 325 | - foreach($meetings as $meeting){ |
|
| 326 | - if($usersMeetingsTmp->contains('meeting_id', $meeting)){ |
|
| 327 | - $ret[$user][$meeting] = 1; |
|
| 328 | - }else{ |
|
| 329 | - $ret[$user][$meeting] = 0; |
|
| 325 | + foreach ($meetings as $meeting) { |
|
| 326 | + if ($usersMeetingsTmp->contains('meeting_id', $meeting)) { |
|
| 327 | + $ret[ $user ][ $meeting ] = 1; |
|
| 328 | + } else { |
|
| 329 | + $ret[ $user ][ $meeting ] = 0; |
|
| 330 | 330 | } |
| 331 | 331 | } |
| 332 | 332 | } |
@@ -340,7 +340,7 @@ discard block |
||
| 340 | 340 | */ |
| 341 | 341 | private function durationConverter($item) |
| 342 | 342 | { |
| 343 | - return $item->each(function($item2){ |
|
| 343 | + return $item->each(function($item2) { |
|
| 344 | 344 | $item2->duration = $this->convertDuration((int) $item2->duration); |
| 345 | 345 | return $item2; |
| 346 | 346 | //TODO try catch |
@@ -353,7 +353,7 @@ discard block |
||
| 353 | 353 | */ |
| 354 | 354 | private function timeSlotsConverter($item) |
| 355 | 355 | { |
| 356 | - return $item->each(function($item2){ |
|
| 356 | + return $item->each(function($item2) { |
|
| 357 | 357 | $item2->time_start = $this->toTimeSlot($item2->time_start); |
| 358 | 358 | $item2->time_end = $this->toTimeSlot($item2->time_end); |
| 359 | 359 | return $item2; |
@@ -366,13 +366,13 @@ discard block |
||
| 366 | 366 | * @param bool|true $free if true the array is filled with 1 for timeslots values else with 0 for timeslots values |
| 367 | 367 | * @return array |
| 368 | 368 | */ |
| 369 | - static private function getAvailabilityArray(\Illuminate\Support\Collection $timeSlots, $timeslotsN, $free=true) |
|
| 369 | + static private function getAvailabilityArray(\Illuminate\Support\Collection $timeSlots, $timeslotsN, $free = true) |
|
| 370 | 370 | { |
| 371 | - $ret = []; |
|
| 372 | - foreach($timeSlots as $id=>$timeSlots2) |
|
| 371 | + $ret = [ ]; |
|
| 372 | + foreach ($timeSlots as $id=>$timeSlots2) |
|
| 373 | 373 | { |
| 374 | - $ret = self::fillTimeSlots($ret, $id, $timeSlots2, $free?'1':'0'); |
|
| 375 | - $ret = self::fillRow($ret, $id, $timeslotsN, $free?'0':'1'); |
|
| 374 | + $ret = self::fillTimeSlots($ret, $id, $timeSlots2, $free ? '1' : '0'); |
|
| 375 | + $ret = self::fillRow($ret, $id, $timeslotsN, $free ? '0' : '1'); |
|
| 376 | 376 | } |
| 377 | 377 | |
| 378 | 378 | return $ret; |
@@ -387,10 +387,10 @@ discard block |
||
| 387 | 387 | */ |
| 388 | 388 | static private function fillTimeSlots(array $array, $id, \Illuminate\Support\Collection $timeSlots, $fill = '0') |
| 389 | 389 | { |
| 390 | - foreach($timeSlots as $timeSlot) { |
|
| 391 | - if(!isset($array[$id])) |
|
| 392 | - $array[$id] = []; |
|
| 393 | - $array[$id] = self::arrayPadInterval($array[$id], $timeSlot->time_start, $timeSlot->time_end, $fill); |
|
| 390 | + foreach ($timeSlots as $timeSlot) { |
|
| 391 | + if (!isset($array[ $id ])) |
|
| 392 | + $array[ $id ] = [ ]; |
|
| 393 | + $array[ $id ] = self::arrayPadInterval($array[ $id ], $timeSlot->time_start, $timeSlot->time_end, $fill); |
|
| 394 | 394 | } |
| 395 | 395 | return $array; |
| 396 | 396 | } |
@@ -403,9 +403,9 @@ discard block |
||
| 403 | 403 | */ |
| 404 | 404 | static private function fillRow(array $array, $id, $until, $fill = '0') |
| 405 | 405 | { |
| 406 | - for($i = 1; $i <= $until; $i++){ |
|
| 407 | - if(!isset($array[$id][$i])) |
|
| 408 | - $array[$id][$i] = $fill; |
|
| 406 | + for ($i = 1; $i <= $until; $i++) { |
|
| 407 | + if (!isset($array[ $id ][ $i ])) |
|
| 408 | + $array[ $id ][ $i ] = $fill; |
|
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | return $array; |
@@ -420,8 +420,8 @@ discard block |
||
| 420 | 420 | */ |
| 421 | 421 | static private function arrayPadInterval(array $array, $from, $to, $pad = '0') |
| 422 | 422 | { |
| 423 | - for($i = $from; $i<$to; $i++) |
|
| 424 | - $array[$i] = $pad; |
|
| 423 | + for ($i = $from; $i < $to; $i++) |
|
| 424 | + $array[ $i ] = $pad; |
|
| 425 | 425 | return $array; |
| 426 | 426 | } |
| 427 | 427 | |
@@ -435,14 +435,14 @@ discard block |
||
| 435 | 435 | { |
| 436 | 436 | $dateTime = new \DateTime($time); |
| 437 | 437 | $diff = $dateTime->diff($this->startTime); |
| 438 | - $diff = explode(':',$diff->format('%R:%d:%h:%i:%s')); |
|
| 439 | - $diff = $diff[1]*86400 + $diff[2]*3600 + $diff[3]*60 + $diff[4]; |
|
| 438 | + $diff = explode(':', $diff->format('%R:%d:%h:%i:%s')); |
|
| 439 | + $diff = $diff[ 1 ] * 86400 + $diff[ 2 ] * 3600 + $diff[ 3 ] * 60 + $diff[ 4 ]; |
|
| 440 | 440 | //if($diff[0] != '-' && $diff != 0) |
| 441 | 441 | // throw new OptimiseException('timeslot time <= startTime'); |
| 442 | 442 | //TODO fix check |
| 443 | 443 | //TODO check if diff makes sense |
| 444 | 444 | //TODO check upper limit |
| 445 | - return (int)(round($diff/self::TIME_SLOT_DURATION)+1); //TODO can round cause overlaps? |
|
| 445 | + return (int) (round($diff / self::TIME_SLOT_DURATION) + 1); //TODO can round cause overlaps? |
|
| 446 | 446 | } |
| 447 | 447 | |
| 448 | 448 | /** |
@@ -452,7 +452,7 @@ discard block |
||
| 452 | 452 | private function toDateTime($timeslot) |
| 453 | 453 | { |
| 454 | 454 | $ret = clone $this->startTime; |
| 455 | - return $ret->add(new \DateInterval('PT'.(($timeslot-1)*self::TIME_SLOT_DURATION).'S')); |
|
| 455 | + return $ret->add(new \DateInterval('PT'.(($timeslot - 1) * self::TIME_SLOT_DURATION).'S')); |
|
| 456 | 456 | } |
| 457 | 457 | |
| 458 | 458 | /** |
@@ -461,6 +461,6 @@ discard block |
||
| 461 | 461 | */ |
| 462 | 462 | static private function convertDuration($duration) |
| 463 | 463 | { |
| 464 | - return (int)ceil($duration/self::TIME_SLOT_DURATION); |
|
| 464 | + return (int) ceil($duration / self::TIME_SLOT_DURATION); |
|
| 465 | 465 | } |
| 466 | 466 | } |
| 467 | 467 | \ No newline at end of file |
@@ -311,10 +311,10 @@ discard block |
||
| 311 | 311 | } |
| 312 | 312 | |
| 313 | 313 | /** |
| 314 | - * @param array $users |
|
| 315 | - * @param array $meetings |
|
| 314 | + * @param string[] $users |
|
| 315 | + * @param string[] $meetings |
|
| 316 | 316 | * @param \Illuminate\Support\Collection $usersMeetings |
| 317 | - * @return array |
|
| 317 | + * @return string[] |
|
| 318 | 318 | */ |
| 319 | 319 | static private function getUsersMeetingsArray($users, $meetings, \Illuminate\Support\Collection $usersMeetings) |
| 320 | 320 | { |
@@ -363,8 +363,9 @@ discard block |
||
| 363 | 363 | |
| 364 | 364 | /** |
| 365 | 365 | * @param \Illuminate\Support\Collection $timeSlots |
| 366 | - * @param bool|true $free if true the array is filled with 1 for timeslots values else with 0 for timeslots values |
|
| 367 | - * @return array |
|
| 366 | + * @param boolean $free if true the array is filled with 1 for timeslots values else with 0 for timeslots values |
|
| 367 | + * @param integer $timeslotsN |
|
| 368 | + * @return string[] |
|
| 368 | 369 | */ |
| 369 | 370 | static private function getAvailabilityArray(\Illuminate\Support\Collection $timeSlots, $timeslotsN, $free=true) |
| 370 | 371 | { |
@@ -3,8 +3,6 @@ |
||
| 3 | 3 | namespace plunner\Listeners; |
| 4 | 4 | |
| 5 | 5 | use plunner\Events\CaldavErrorEvent; |
| 6 | -use Illuminate\Queue\InteractsWithQueue; |
|
| 7 | -use Illuminate\Contracts\Queue\ShouldQueue; |
|
| 8 | 6 | |
| 9 | 7 | class CaldavErrorListener |
| 10 | 8 | { |
@@ -38,7 +38,7 @@ |
||
| 38 | 38 | */ |
| 39 | 39 | static private function sendEmail($email, $error) |
| 40 | 40 | { |
| 41 | - \Mail::queue('emails.optimise.error', ['error' => $error], function ($message) use($email) { |
|
| 41 | + \Mail::queue('emails.optimise.error', [ 'error' => $error ], function($message) use($email) { |
|
| 42 | 42 | $message->from(config('mail.from.address'), config('mail.from.name')); |
| 43 | 43 | $message->to($email)->subject('Problems during optimisation'); |
| 44 | 44 | }); |