@@ -33,14 +33,14 @@ |
||
33 | 33 | |
34 | 34 | static private function company() |
35 | 35 | { |
36 | - factory(plunner\Company::class, 10)->create()->each(function ($company) { |
|
36 | + factory(plunner\Company::class, 10)->create()->each(function($company) { |
|
37 | 37 | self::employees($company); |
38 | 38 | }); |
39 | 39 | } |
40 | 40 | |
41 | 41 | static private function employees($company) |
42 | 42 | { |
43 | - factory(plunner\Employee::class, 3)->make()->each(function ($employee) use($company){ |
|
43 | + factory(plunner\Employee::class, 3)->make()->each(function($employee) use($company){ |
|
44 | 44 | $company->employees()->save($employee); |
45 | 45 | }); |
46 | 46 | } |
@@ -104,6 +104,6 @@ |
||
104 | 104 | | |
105 | 105 | */ |
106 | 106 | |
107 | - 'attributes' => [], |
|
107 | + 'attributes' => [ ], |
|
108 | 108 | |
109 | 109 | ]; |
@@ -8,7 +8,7 @@ |
||
8 | 8 | */ |
9 | 9 | |
10 | 10 | $uri = urldecode( |
11 | - parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) |
|
11 | + parse_url($_SERVER[ 'REQUEST_URI' ], PHP_URL_PATH) |
|
12 | 12 | ); |
13 | 13 | |
14 | 14 | // This file allows us to emulate Apache's "mod_rewrite" functionality from the |
@@ -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 | { |
@@ -46,11 +46,11 @@ discard block |
||
46 | 46 | * @param array $payload |
47 | 47 | * @return mixed |
48 | 48 | */ |
49 | - protected function respond($event, $error, $status, $payload = []) |
|
49 | + protected function respond($event, $error, $status, $payload = [ ]) |
|
50 | 50 | { |
51 | 51 | $response = $this->events->fire($event, $payload, true); |
52 | 52 | |
53 | - return $response ?: $this->response->json(['error' => $error], $status); |
|
53 | + return $response ?: $this->response->json([ 'error' => $error ], $status); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | |
@@ -59,14 +59,14 @@ discard block |
||
59 | 59 | * @param String $str |
60 | 60 | * @return array |
61 | 61 | */ |
62 | - protected function convertToArray($str){ |
|
63 | - $ret = []; |
|
62 | + protected function convertToArray($str) { |
|
63 | + $ret = [ ]; |
|
64 | 64 | $str = explode(';', $str); |
65 | - foreach($str as $value) { |
|
65 | + foreach ($str as $value) { |
|
66 | 66 | $tmp = explode('-', $value); |
67 | - if(count($tmp) != 2) |
|
68 | - return []; |
|
69 | - $ret[$tmp[0]] = $tmp[1]; |
|
67 | + if (count($tmp) != 2) |
|
68 | + return [ ]; |
|
69 | + $ret[ $tmp[ 0 ] ] = $tmp[ 1 ]; |
|
70 | 70 | } |
71 | 71 | return $ret; |
72 | 72 | } |
@@ -22,27 +22,27 @@ discard block |
||
22 | 22 | { |
23 | 23 | $custom = $this->convertToArray($custom); |
24 | 24 | $headers = $request->headers->all(); |
25 | - foreach($headers as $key=>$header) |
|
26 | - Log::info($key.': '.implode('-',$header)); |
|
25 | + foreach ($headers as $key=>$header) |
|
26 | + Log::info($key.': '.implode('-', $header)); |
|
27 | 27 | |
28 | - if($token = $this->auth->setRequest($request)->getToken()) { |
|
29 | - }else if ($this->auth->getUserModel()){ |
|
28 | + if ($token = $this->auth->setRequest($request)->getToken()) { |
|
29 | + } else if ($this->auth->getUserModel()) { |
|
30 | 30 | $token = $this->auth->fromUser($this->auth->getUserModel(), $custom); |
31 | - }else { |
|
31 | + } else { |
|
32 | 32 | return $this->respond('tymon.jwt.absent', 'token_not_provided', 401); |
33 | 33 | } |
34 | 34 | |
35 | 35 | try { |
36 | 36 | $user = $this->auth->authenticate($token, $custom); |
37 | 37 | } catch (TokenExpiredException $e) { |
38 | - return $this->respond('tymon.jwt.expired', 'token_expired', $e->getStatusCode(), [$e]); |
|
39 | - } catch(InvalidClaimException $e) { |
|
40 | - return $this->respond('tymon.jwt.invalid', 'claim_invalid', $e->getStatusCode(), [$e]); |
|
38 | + return $this->respond('tymon.jwt.expired', 'token_expired', $e->getStatusCode(), [ $e ]); |
|
39 | + } catch (InvalidClaimException $e) { |
|
40 | + return $this->respond('tymon.jwt.invalid', 'claim_invalid', $e->getStatusCode(), [ $e ]); |
|
41 | 41 | } catch (JWTException $e) { |
42 | - return $this->respond('tymon.jwt.invalid', 'token_invalid', $e->getStatusCode(), [$e]); |
|
42 | + return $this->respond('tymon.jwt.invalid', 'token_invalid', $e->getStatusCode(), [ $e ]); |
|
43 | 43 | } |
44 | 44 | |
45 | - if (! $user) { |
|
45 | + if (!$user) { |
|
46 | 46 | return $this->respond('tymon.jwt.user_not_found', 'user_not_found', 404); |
47 | 47 | } |
48 | 48 | |
@@ -58,13 +58,13 @@ discard block |
||
58 | 58 | try { |
59 | 59 | $newToken = $this->auth->refresh($token, $custom); |
60 | 60 | } catch (TokenExpiredException $e) { |
61 | - return $this->respond('tymon.jwt.expired', 'token_expired', $e->getStatusCode(), [$e]); |
|
61 | + return $this->respond('tymon.jwt.expired', 'token_expired', $e->getStatusCode(), [ $e ]); |
|
62 | 62 | } catch (JWTException $e) { |
63 | - return $this->respond('tymon.jwt.invalid', 'token_invalid', $e->getStatusCode(), [$e]); |
|
63 | + return $this->respond('tymon.jwt.invalid', 'token_invalid', $e->getStatusCode(), [ $e ]); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | // send the refreshed token back to the client |
67 | - $response->headers->set('Authorization', 'Bearer ' . $newToken); |
|
67 | + $response->headers->set('Authorization', 'Bearer '.$newToken); |
|
68 | 68 | |
69 | 69 | return $response; |
70 | 70 | } |
@@ -12,11 +12,11 @@ |
||
12 | 12 | | |
13 | 13 | */ |
14 | 14 | 'supportsCredentials' => false, |
15 | - 'allowedOrigins' => ['*'], |
|
16 | - 'allowedHeaders' => ['*'], |
|
17 | - 'allowedMethods' => ['GET', 'POST', 'PUT', 'DELETE'], |
|
18 | - 'exposedHeaders' => ['authorization'], |
|
15 | + 'allowedOrigins' => [ '*' ], |
|
16 | + 'allowedHeaders' => [ '*' ], |
|
17 | + 'allowedMethods' => [ 'GET', 'POST', 'PUT', 'DELETE' ], |
|
18 | + 'exposedHeaders' => [ 'authorization' ], |
|
19 | 19 | 'maxAge' => 0, |
20 | - 'hosts' => [], |
|
20 | + 'hosts' => [ ], |
|
21 | 21 | ]; |
22 | 22 |
@@ -50,10 +50,10 @@ discard block |
||
50 | 50 | $input = $request->all(); |
51 | 51 | |
52 | 52 | $g = Group::create([ |
53 | - 'name' => $input['group_name'], |
|
54 | - 'description' => isset($input['description']) ? $input['description'] : '' |
|
53 | + 'name' => $input[ 'group_name' ], |
|
54 | + 'description' => isset($input[ 'description' ]) ? $input[ 'description' ] : '' |
|
55 | 55 | ]); |
56 | - $employees = Employee::whereIn('name', $input['employees'])->get(); |
|
56 | + $employees = Employee::whereIn('name', $input[ 'employees' ])->get(); |
|
57 | 57 | |
58 | 58 | $g->addEmployees($employees); |
59 | 59 | |
@@ -94,15 +94,15 @@ discard block |
||
94 | 94 | $this->validateGroupUpdates($request); |
95 | 95 | $input = $request->all(); |
96 | 96 | |
97 | - $employees = Employee::whereIn('name', $input['employees'])->get(); |
|
97 | + $employees = Employee::whereIn('name', $input[ 'employees' ])->get(); |
|
98 | 98 | |
99 | 99 | try { |
100 | - $group = Group::findOrFail($input['group_name']); |
|
100 | + $group = Group::findOrFail($input[ 'group_name' ]); |
|
101 | 101 | } catch (ModelNotFoundException $e) { |
102 | 102 | return $this->responder->respond( |
103 | 103 | [ |
104 | 104 | 'message' => 'Group not found', |
105 | - 'group_name' => $input['group_name'] |
|
105 | + 'group_name' => $input[ 'group_name' ] |
|
106 | 106 | ], |
107 | 107 | 404 |
108 | 108 | ); |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | |
123 | 123 | private function respondOK() |
124 | 124 | { |
125 | - return $this->responder->respond([], 200); |
|
125 | + return $this->responder->respond([ ], 200); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
@@ -22,7 +22,7 @@ |
||
22 | 22 | { |
23 | 23 | $app = $this->app; |
24 | 24 | |
25 | - $app->singleton('Services\ServiceCreator\ResponseCreator', function ($app) { |
|
25 | + $app->singleton('Services\ServiceCreator\ResponseCreator', function($app) { |
|
26 | 26 | return new services\serviceCreator\JsonResponseCreator(); |
27 | 27 | }); |
28 | 28 | } |