Completed
Push — master ( f14b58...7fe11b )
by claudio
06:54
created
app/Company.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -48,14 +48,14 @@  discard block
 block discarded – undo
48 48
      *
49 49
      * @var array
50 50
      */
51
-    protected $fillable = ['name', 'email', 'password'];
51
+    protected $fillable = [ 'name', 'email', 'password' ];
52 52
 
53 53
     /**
54 54
      * The attributes excluded from the model's JSON form.
55 55
      *
56 56
      * @var array
57 57
      */
58
-    protected $hidden = ['password', 'remember_token'];
58
+    protected $hidden = [ 'password', 'remember_token' ];
59 59
 
60 60
     /**
61 61
      * @return \Illuminate\Database\Eloquent\Relations\HasMany
@@ -120,8 +120,8 @@  discard block
 block discarded – undo
120 120
             ->where('calendars.enabled', '=', '1')
121 121
             ->where('timeslots.time_start', '>=', $from)
122 122
             ->where('timeslots.time_end', '<=', $to)
123
-            ->where('employees.company_id','=', $this->id)
124
-            ->select('employees.id','timeslots.time_start','timeslots.time_end')
123
+            ->where('employees.company_id', '=', $this->id)
124
+            ->select('employees.id', 'timeslots.time_start', 'timeslots.time_end')
125 125
             ->get();
126 126
     }
127 127
 
@@ -137,9 +137,9 @@  discard block
 block discarded – undo
137 137
             ->join('meeting_timeslots', 'meetings.id', '=', 'meeting_timeslots.meeting_id')
138 138
             ->where('meeting_timeslots.time_start', '>=', $from)
139 139
             ->where('meeting_timeslots.time_end', '<=', $to)
140
-            ->where('groups.company_id','=', $this->id)
141
-            ->where('meetings.start_time','=', NULL)
142
-            ->select('meetings.id', 'meetings.duration','meeting_timeslots.time_start','meeting_timeslots.time_end')
140
+            ->where('groups.company_id', '=', $this->id)
141
+            ->where('meetings.start_time', '=', NULL)
142
+            ->select('meetings.id', 'meetings.duration', 'meeting_timeslots.time_start', 'meeting_timeslots.time_end')
143 143
             ->get();
144 144
     }
145 145
 
@@ -151,8 +151,8 @@  discard block
 block discarded – undo
151 151
             ->join('employees', 'employee_group.employee_id', '=', 'employees.id')
152 152
             ->whereIn('employees.id', $users)
153 153
             ->whereIn('meetings.id', $meetings)
154
-            ->where('groups.company_id','=', $this->id) //this is not needed
155
-            ->where('employees.company_id','=', $this->id) //this is not needed
154
+            ->where('groups.company_id', '=', $this->id) //this is not needed
155
+            ->where('employees.company_id', '=', $this->id) //this is not needed
156 156
             ->select('employees.id as employee_id', 'meetings.id as meeting_id')
157 157
             ->get();
158 158
     }
Please login to merge, or discard this patch.
app/Console/Commands/Optimise/Solver.php 1 patch
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
      */
113 113
     static private function checkGlpsol()
114 114
     {
115
-        if(!(`which glpsol`))
115
+        if (!(`which glpsol`))
116 116
             throw new OptimiseException('glpsol is not installed');
117 117
     }
118 118
 
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
      */
194 194
     public function setTimeSlots($timeSlots)
195 195
     {
196
-        if(!is_int($timeSlots) || $timeSlots <=0)
196
+        if (!is_int($timeSlots) || $timeSlots <= 0)
197 197
             throw new OptimiseException('$timeSlots is not integer or it is not >0');
198 198
 
199 199
         $this->timeSlots = $timeSlots;
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
      */
216 216
     public function setMaxTimeSlots($maxTimeSlots)
217 217
     {
218
-        if(!is_int($maxTimeSlots) || $maxTimeSlots <=0)
218
+        if (!is_int($maxTimeSlots) || $maxTimeSlots <= 0)
219 219
             throw new OptimiseException('$maxTimeSlots is not integer or it is not >0');
220 220
 
221 221
         $this->maxTimeSlots = $maxTimeSlots;
@@ -238,13 +238,13 @@  discard block
 block discarded – undo
238 238
     public function setMeetingsAvailability($meetingsAvailability)
239 239
     {
240 240
         $meetings = array_keys($meetingsAvailability);
241
-        if(array_diff($meetings, $this->meetings))
241
+        if (array_diff($meetings, $this->meetings))
242 242
             throw new OptimiseException('meetings different from meetings set');
243
-        foreach($meetingsAvailability as $key=>$meetingsAvailabilityS) {
243
+        foreach ($meetingsAvailability as $key=>$meetingsAvailabilityS) {
244 244
             $timeSlots = array_keys($meetingsAvailabilityS);
245
-            if(count($timeSlots) != $this->timeSlots)
245
+            if (count($timeSlots) != $this->timeSlots)
246 246
                 throw new OptimiseException('timeSlots different from timeSlots set');
247
-            $meetingsAvailability[$key] = self::arrayPad($meetingsAvailabilityS, $this->timeSlots + $this->maxTimeSlots, 0);
247
+            $meetingsAvailability[ $key ] = self::arrayPad($meetingsAvailabilityS, $this->timeSlots + $this->maxTimeSlots, 0);
248 248
         }
249 249
 
250 250
         $this->meetingsAvailability = $meetingsAvailability;
@@ -267,13 +267,13 @@  discard block
 block discarded – undo
267 267
     public function setMeetingsDuration($meetingsDuration)
268 268
     {
269 269
         $meetings = array_keys($meetingsDuration);
270
-        if(array_diff($meetings, $this->meetings)) {
270
+        if (array_diff($meetings, $this->meetings)) {
271 271
             print "";
272 272
             throw new OptimiseException('meetings different from meetings set');
273 273
         }
274
-        foreach($meetingsDuration as $duration) {
274
+        foreach ($meetingsDuration as $duration) {
275 275
             $duration = (int) $duration; //TODO fix this (fix for optimise)
276
-            if(!is_int($duration) || $duration <=0)
276
+            if (!is_int($duration) || $duration <= 0)
277 277
                 throw new OptimiseException('duration is not integer or it is not >0');
278 278
         }
279 279
 
@@ -297,14 +297,14 @@  discard block
 block discarded – undo
297 297
     public function setUsersAvailability($usersAvailability)
298 298
     {
299 299
         $users = array_keys($usersAvailability);
300
-        if(array_diff($users, $this->users))
300
+        if (array_diff($users, $this->users))
301 301
             throw new OptimiseException('users different from users set');
302
-        foreach($usersAvailability as $key=>$usersAvailabilityS) {
302
+        foreach ($usersAvailability as $key=>$usersAvailabilityS) {
303 303
             $timeSlots = array_keys($usersAvailabilityS);
304
-            if(count($timeSlots) != $this->timeSlots)
304
+            if (count($timeSlots) != $this->timeSlots)
305 305
                 throw new OptimiseException('timeSlots different from timeSlots set');
306 306
 
307
-            $usersAvailability[$key] = self::arrayPad($usersAvailabilityS, $this->timeSlots + $this->maxTimeSlots, 0);
307
+            $usersAvailability[ $key ] = self::arrayPad($usersAvailabilityS, $this->timeSlots + $this->maxTimeSlots, 0);
308 308
         }
309 309
 
310 310
         $this->usersAvailability = $usersAvailability;
@@ -327,11 +327,11 @@  discard block
 block discarded – undo
327 327
     public function setUsersMeetings($usersMeetings)
328 328
     {
329 329
         $users = array_keys($usersMeetings);
330
-        if(array_diff($users, $this->users))
330
+        if (array_diff($users, $this->users))
331 331
             throw new OptimiseException('users different from users set');
332
-        foreach($usersMeetings as $usersMeetingsS) {
332
+        foreach ($usersMeetings as $usersMeetingsS) {
333 333
             $meetings = array_keys($usersMeetingsS);
334
-            if(array_diff($meetings, $this->meetings))
334
+            if (array_diff($meetings, $this->meetings))
335 335
                 throw new OptimiseException('meetings different from meetings set');
336 336
         }
337 337
 
@@ -394,13 +394,13 @@  discard block
 block discarded – undo
394 394
      */
395 395
     static private function writeCSVArrayNoKey($file, $data)
396 396
     {
397
-        $f = function ($fp, $data){
397
+        $f = function($fp, $data) {
398 398
             foreach ($data as $field) {
399
-                fputcsv($fp, [$field]);
399
+                fputcsv($fp, [ $field ]);
400 400
             }
401 401
         };
402 402
 
403
-        self::writeCSV($file, $data, ['i'], $f);
403
+        self::writeCSV($file, $data, [ 'i' ], $f);
404 404
     }
405 405
 
406 406
     /**
@@ -411,13 +411,13 @@  discard block
 block discarded – undo
411 411
      */
412 412
     static private function writeCSVArray($file, $data, $name)
413 413
     {
414
-        $f = function ($fp, $data){
414
+        $f = function($fp, $data) {
415 415
             foreach ($data as $key=>$field) {
416
-                fputcsv($fp, [$key, $field]);
416
+                fputcsv($fp, [ $key, $field ]);
417 417
             }
418 418
         };
419 419
 
420
-        self::writeCSV($file, $data, ['i', $name], $f);
420
+        self::writeCSV($file, $data, [ 'i', $name ], $f);
421 421
     }
422 422
 
423 423
     /**
@@ -428,14 +428,14 @@  discard block
 block discarded – undo
428 428
      */
429 429
     static private function writeCSVMatrix($file, $data, $name)
430 430
     {
431
-        $f = function ($fp, $data){
431
+        $f = function($fp, $data) {
432 432
             foreach ($data as $key=>$field) {
433 433
                 foreach ($field as $key2=>$field2)
434
-                    fputcsv($fp, [$key, $key2, $field2]);
434
+                    fputcsv($fp, [ $key, $key2, $field2 ]);
435 435
             }
436 436
         };
437 437
 
438
-        self::writeCSV($file, $data, ['i', 'j', $name], $f);
438
+        self::writeCSV($file, $data, [ 'i', 'j', $name ], $f);
439 439
     }
440 440
 
441 441
     /**
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
     static private function writeCSV($file, $data, $heading, \Closure $writer)
449 449
     {
450 450
         $fp = @fopen($file, 'w');
451
-        if(!$fp)
451
+        if (!$fp)
452 452
             throw new OptimiseException('problem during creation of a file');
453 453
 
454 454
         fputcsv($fp, $heading);
@@ -468,8 +468,8 @@  discard block
 block discarded – undo
468 468
     {
469 469
         $this->writeData();
470 470
         $this->writeModelFile();
471
-        $event = $this->schedule->exec('glpsol --math '.$this->path->getModelPath())->sendOutputTo($this->path->getOutputPath())->after(function () { }); //this just to execute in foreground
472
-        if($event->isDue($this->laravel))
471
+        $event = $this->schedule->exec('glpsol --math '.$this->path->getModelPath())->sendOutputTo($this->path->getOutputPath())->after(function() { }); //this just to execute in foreground
472
+        if ($event->isDue($this->laravel))
473 473
             $event->run($this->laravel);
474 474
         //TODO catch glpsol errors
475 475
         return $this;
@@ -483,9 +483,9 @@  discard block
 block discarded – undo
483 483
         $strReplaceS = array('{USERS_PATH}', '{MEETINGS_PATH}', '{USER_AVAILABILITY_PATH}', '{MEETINGS_AVAILABILITY_PATH}', '{USER_MEETINGS_PATH}', '{MEETINGS_DURATION_PATH}', '{TIME_SLOTS}', '{MAX_TIME_SLOTS}', '{X_OUT_PATH}', '{Y_OUT_PATH}');
484 484
         $strReplaceR = array($this->path->getUsersPath(), $this->path->getMeetingsPath(), $this->path->getUsersAvailabilityPath(), $this->path->getMeetingsAvailabilityPath(), $this->path->getUsersMeetingsPath(), $this->path->getMeetingsDurationPath(), $this->timeSlots, $this->maxTimeSlots, $this->path->getXPath(), $this->path->getYPath());
485 485
         $f = @fopen($this->path->getModelPath(), "w");
486
-        if(!$f)
486
+        if (!$f)
487 487
             throw new OptimiseException('problem during creation of a file');
488
-        fwrite($f, str_replace($strReplaceS, $strReplaceR, file_get_contents(__DIR__ . "/model.stub")));
488
+        fwrite($f, str_replace($strReplaceS, $strReplaceR, file_get_contents(__DIR__."/model.stub")));
489 489
         fclose($f);
490 490
     }
491 491
 
@@ -513,7 +513,7 @@  discard block
 block discarded – undo
513 513
      */
514 514
     public function getOutput()
515 515
     {
516
-        if(!($data = file_get_contents($this->path->getOutputPath())))
516
+        if (!($data = file_get_contents($this->path->getOutputPath())))
517 517
             throw new OptimiseException('problems during reading the file');
518 518
         return $data;
519 519
     }
@@ -525,22 +525,22 @@  discard block
 block discarded – undo
525 525
      */
526 526
     static private function readCSVFile($file)
527 527
     {
528
-        if(!file_exists($file) || !filesize($file))
528
+        if (!file_exists($file) || !filesize($file))
529 529
             throw new OptimiseException('no results file');
530 530
 
531
-        $handle = @fopen($file,"r");
532
-        if(!$handle)
531
+        $handle = @fopen($file, "r");
532
+        if (!$handle)
533 533
             throw new OptimiseException('problems during reading the file');
534 534
 
535
-        $ret = [];
535
+        $ret = [ ];
536 536
         fgetcsv($handle); //skip head
537 537
         while (($data = fgetcsv($handle)) !== FALSE) {
538
-            if(count($data) != 3) {
538
+            if (count($data) != 3) {
539 539
                 fclose($handle);
540 540
                 throw new OptimiseException('problems during parsing the file');
541 541
             }
542 542
 
543
-            $ret[$data[0]][$data[1]] = $data[2];
543
+            $ret[ $data[ 0 ] ][ $data[ 1 ] ] = $data[ 2 ];
544 544
         }
545 545
 
546 546
         fclose($handle);
@@ -567,8 +567,8 @@  discard block
 block discarded – undo
567 567
      */
568 568
     private function checkData()
569 569
     {
570
-        $this->checkArrayProprieties(['users', 'meetings', 'meetingsAvailability', 'meetingsDuration', 'usersAvailability', 'usersMeetings']);
571
-        $this->checkIntProprieties(['timeSlots', 'maxTimeSlots']);
570
+        $this->checkArrayProprieties([ 'users', 'meetings', 'meetingsAvailability', 'meetingsDuration', 'usersAvailability', 'usersMeetings' ]);
571
+        $this->checkIntProprieties([ 'timeSlots', 'maxTimeSlots' ]);
572 572
     }
573 573
 
574 574
     /**
@@ -577,8 +577,8 @@  discard block
 block discarded – undo
577 577
      */
578 578
     private function checkArrayProprieties($proprieties)
579 579
     {
580
-        foreach($proprieties as $propriety)
581
-            if(count($this->$propriety)==0)
580
+        foreach ($proprieties as $propriety)
581
+            if (count($this->$propriety) == 0)
582 582
                 throw new OptimiseException($propriety.' is not set correctly');
583 583
     }
584 584
 
@@ -588,8 +588,8 @@  discard block
 block discarded – undo
588 588
      */
589 589
     private function checkIntProprieties($proprieties)
590 590
     {
591
-        foreach($proprieties as $propriety)
592
-            if(!is_int($this->$propriety) || $this->$propriety <= 0)
591
+        foreach ($proprieties as $propriety)
592
+            if (!is_int($this->$propriety) || $this->$propriety <= 0)
593 593
                 throw new OptimiseException($propriety.' is not set correctly');
594 594
     }
595 595
 
@@ -602,8 +602,8 @@  discard block
 block discarded – undo
602 602
     static private function arrayPad(array $array, $len, $pad)
603 603
     {
604 604
         $len = $len - count($array);
605
-        for($i = 0; $i<$len; $i++)
606
-            $array[] = $pad;
605
+        for ($i = 0; $i < $len; $i++)
606
+            $array[ ] = $pad;
607 607
         return $array;
608 608
     }
609 609
 }
610 610
\ No newline at end of file
Please login to merge, or discard this patch.
app/Console/Commands/Optimise/Path.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -76,11 +76,11 @@  discard block
 block discarded – undo
76 76
     {
77 77
         $path = new Path(tempnam(sys_get_temp_dir(), 'OPT')); //TODO check the return in case of errors this return false on failure
78 78
         unlink($path->getPath()); //remove file to create a dir
79
-        if(file_exists($path->getPath()))
79
+        if (file_exists($path->getPath()))
80 80
             throw new OptimiseException('problem during creation of tmp dir (the directory already exists)');
81
-        if(!@mkdir($path->getPath()))
82
-            throw new OptimiseException('problem during creation of tmp dir (mkdir problem)');;
83
-        if(! is_dir($path->getPath()))
81
+        if (!@mkdir($path->getPath()))
82
+            throw new OptimiseException('problem during creation of tmp dir (mkdir problem)'); ;
83
+        if (!is_dir($path->getPath()))
84 84
             throw new OptimiseException('problem during creation of tmp dir (it is not possible to create directory)');
85 85
         return $path;
86 86
     }
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
      * @return bool
92 92
      */
93 93
     private static function delTree($dir) {
94
-        $files = array_diff(scandir($dir), array('.','..'));
94
+        $files = array_diff(scandir($dir), array('.', '..'));
95 95
         foreach ($files as $file) {
96 96
             (is_dir("$dir/$file")) ? delTree("$dir/$file") : unlink("$dir/$file");
97 97
         }
Please login to merge, or discard this patch.
app/Listeners/Optimise/OkListener.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
         self::sendCompanyEmail($event->getCompany()->email);
34 34
         //send emails to employees
35 35
         $employees = $event->getCompany()->employees()->with('meetings')->get();
36
-        foreach($employees as $employee)
36
+        foreach ($employees as $employee)
37 37
             self::sendEmployeeEmail($employee->email, $employee->meetings);
38 38
     }
39 39
 
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
      */
43 43
     static private function sendCompanyEmail($email)
44 44
     {
45
-        \Mail::queue('emails.optimise.ok.company', [], function ($message) use($email) {
45
+        \Mail::queue('emails.optimise.ok.company', [ ], function($message) use($email) {
46 46
             $message->from(config('mail.from.address'), config('mail.from.name'));
47 47
             $message->to($email)->subject('Meetings optimised');
48 48
         });
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
      */
55 55
     static private function sendEmployeeEmail($email, $meetings)
56 56
     {
57
-        \Mail::queue('emails.optimise.ok.employee', ['meetings' => $meetings], function ($message) use($email) {
57
+        \Mail::queue('emails.optimise.ok.employee', [ 'meetings' => $meetings ], function($message) use($email) {
58 58
             $message->from(config('mail.from.address'), config('mail.from.name'));
59 59
             $message->to($email)->subject('Meetings of next week');
60 60
         });
Please login to merge, or discard this patch.
app/Listeners/Optimise/ErrorListener.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@
 block discarded – undo
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
         });
Please login to merge, or discard this patch.
app/Http/Controllers/Employees/Auth/AuthController.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
      * en = employee normal
44 44
      * @var array
45 45
      */
46
-    protected $custom = ['mode'=>'en'];
46
+    protected $custom = [ 'mode'=>'en' ];
47 47
 
48 48
     /**
49 49
      * @var company
@@ -56,8 +56,8 @@  discard block
 block discarded – undo
56 56
      */
57 57
     public function __construct()
58 58
     {
59
-        config(['auth.model' => \plunner\Employee::class]);
60
-        config(['jwt.user' => \plunner\Employee::class]);
59
+        config([ 'auth.model' => \plunner\Employee::class ]);
60
+        config([ 'jwt.user' => \plunner\Employee::class ]);
61 61
     }
62 62
 
63 63
     /**
@@ -84,15 +84,15 @@  discard block
 block discarded – undo
84 84
     protected function create(array $data)
85 85
     {
86 86
         return $this->company->save(new employee([
87
-            'name' => $data['name'],
88
-            'email' => $data['email'],
89
-            'password' => bcrypt($data['password']),
87
+            'name' => $data[ 'name' ],
88
+            'email' => $data[ 'email' ],
89
+            'password' => bcrypt($data[ 'password' ]),
90 90
         ]));
91 91
     }
92 92
 
93 93
     public function postRegister(Request $request)
94 94
     {
95
-        $this->validate($request, ['company' => 'required|exists:companies,name']);
95
+        $this->validate($request, [ 'company' => 'required|exists:companies,name' ]);
96 96
         $this->company = Company::whereName($request->input('company'))->firstOrFail();
97 97
         return $this->postRegisterOriginal($request);
98 98
     }
@@ -101,18 +101,18 @@  discard block
 block discarded – undo
101 101
     public function postLogin(Request $request)
102 102
     {
103 103
         //get company ID and impiled it in the request
104
-        $this->validate($request, ['company' => 'required|exists:companies,name']);
104
+        $this->validate($request, [ 'company' => 'required|exists:companies,name' ]);
105 105
         $this->company = Company::whereName($request->input('company'))->firstOrFail();
106
-        $request->merge(['company_id' => $this->company->id]);
106
+        $request->merge([ 'company_id' => $this->company->id ]);
107 107
 
108 108
         //remember me
109
-        $this->validate($request, ['remember' => 'boolean']);//TODO insert required
110
-        if($request->input('remember', false))
109
+        $this->validate($request, [ 'remember' => 'boolean' ]); //TODO insert required
110
+        if ($request->input('remember', false))
111 111
         {
112
-            config(['jwt.ttl' =>'43200']); //30 days
113
-            $this->custom = array_merge($this->custom, ['remember'=>'true']);
114
-        }else
115
-            $this->custom = array_merge($this->custom, ['remember'=>'false']);
112
+            config([ 'jwt.ttl' =>'43200' ]); //30 days
113
+            $this->custom = array_merge($this->custom, [ 'remember'=>'true' ]);
114
+        } else
115
+            $this->custom = array_merge($this->custom, [ 'remember'=>'false' ]);
116 116
 
117 117
         return $this->postLoginOriginal($request);
118 118
     }
Please login to merge, or discard this patch.
app/Http/Controllers/Companies/Auth/AuthController.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
      * cn = company normal
41 41
      * @var array
42 42
      */
43
-    protected $custom = ['mode'=>'cn'];
43
+    protected $custom = [ 'mode'=>'cn' ];
44 44
 
45 45
     /**
46 46
      * Create a new authentication controller instance.
@@ -48,8 +48,8 @@  discard block
 block discarded – undo
48 48
      */
49 49
     public function __construct()
50 50
     {
51
-        config(['auth.model' => \plunner\Company::class]);
52
-        config(['jwt.user' => \plunner\Company::class]);
51
+        config([ 'auth.model' => \plunner\Company::class ]);
52
+        config([ 'jwt.user' => \plunner\Company::class ]);
53 53
     }
54 54
 
55 55
     /**
@@ -76,22 +76,22 @@  discard block
 block discarded – undo
76 76
     protected function create(array $data)
77 77
     {
78 78
         return Company::create([
79
-            'name' => $data['name'],
80
-            'email' => $data['email'],
81
-            'password' => bcrypt($data['password']),
79
+            'name' => $data[ 'name' ],
80
+            'email' => $data[ 'email' ],
81
+            'password' => bcrypt($data[ 'password' ]),
82 82
         ]);
83 83
     }
84 84
 
85 85
     public function postLogin(Request $request)
86 86
     {
87 87
         //remember me
88
-        $this->validate($request, ['remember' => 'boolean']);//TODO insert required
89
-        if($request->input('remember', false))
88
+        $this->validate($request, [ 'remember' => 'boolean' ]); //TODO insert required
89
+        if ($request->input('remember', false))
90 90
         {
91
-            config(['jwt.ttl' =>'43200']); //30 days
92
-            $this->custom = array_merge($this->custom, ['remember'=>'true']);
93
-        }else
94
-            $this->custom = array_merge($this->custom, ['remember'=>'false']);
91
+            config([ 'jwt.ttl' =>'43200' ]); //30 days
92
+            $this->custom = array_merge($this->custom, [ 'remember'=>'true' ]);
93
+        } else
94
+            $this->custom = array_merge($this->custom, [ 'remember'=>'false' ]);
95 95
         return $this->postLoginOriginal($request);
96 96
     }
97 97
 
Please login to merge, or discard this patch.
app/Http/Kernel.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -30,6 +30,6 @@
 block discarded – undo
30 30
         'auth' => \plunner\Http\Middleware\Authenticate::class,
31 31
         'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
32 32
         'guest' => \plunner\Http\Middleware\RedirectIfAuthenticated::class,
33
-        'jwt.authandrefresh' =>  \plunner\Http\Middleware\GetUserAndRefresh::class,//'Tymon\JWTAuth\Middleware\GetUserAndRefresh',
33
+        'jwt.authandrefresh' =>  \plunner\Http\Middleware\GetUserAndRefresh::class, //'Tymon\JWTAuth\Middleware\GetUserAndRefresh',
34 34
     ];
35 35
 }
Please login to merge, or discard this patch.
app/Http/Middleware/GetUserAndRefresh.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -25,15 +25,15 @@
 block discarded – undo
25 25
     public function handle($request, \Closure $next, $custom = '')
26 26
     {
27 27
         $remember = false;
28
-        if($this->auth->setRequest($request)->getToken() && ($remember = $this->auth->getPayload()->get('remember')) &&
29
-                $remember == 'true'){
28
+        if ($this->auth->setRequest($request)->getToken() && ($remember = $this->auth->getPayload()->get('remember')) &&
29
+                $remember == 'true') {
30 30
             JWTFactory::setTTL(43200);
31 31
             //config(['jwt.ttl' =>'43200']); //30 days
32 32
         }
33 33
 
34 34
         //this to add the remember me mode field in the new token, but we have the custom check that is an useless
35 35
         //overhead
36
-        $custom = $custom.';remember-'.$remember=='true'?'true':'false';
36
+        $custom = $custom.';remember-'.$remember == 'true' ? 'true' : 'false';
37 37
         return parent::handle($request, $next, $custom);
38 38
     }
39 39
 
Please login to merge, or discard this patch.