@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | */ |
16 | 16 | public function __construct() |
17 | 17 | { |
18 | - $this->middleware('auth:api', ['except' => ['login']]); |
|
18 | + $this->middleware('auth:api', [ 'except' => [ 'login' ] ]); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | /** |
@@ -34,9 +34,9 @@ discard block |
||
34 | 34 | $input = $request->only('email', 'password'); |
35 | 35 | $validator = Validator::make($input, $rules); |
36 | 36 | |
37 | - if($validator->fails()) { |
|
37 | + if ($validator->fails()) { |
|
38 | 38 | $error = $validator->messages(); |
39 | - return response()->json(['success'=> false, 'error'=> $error]); |
|
39 | + return response()->json([ 'success'=> false, 'error'=> $error ]); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | $credentials = [ |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | |
47 | 47 | try { |
48 | 48 | // attempt to verify the credentials and create a token for the user |
49 | - if (! $token = JWTAuth::attempt($credentials)) { |
|
49 | + if (!$token = JWTAuth::attempt($credentials)) { |
|
50 | 50 | |
51 | 51 | //Check if it exists a user to validate |
52 | 52 | $user = User::where('email', $request->email)->first(); |
@@ -58,15 +58,15 @@ discard block |
||
58 | 58 | |
59 | 59 | return $user; |
60 | 60 | |
61 | - return response()->json(['success' => false, 'error' => 'Invalid Credentials. Please make sure you entered the right information and you have verified your email address.'], 401); |
|
61 | + return response()->json([ 'success' => false, 'error' => 'Invalid Credentials. Please make sure you entered the right information and you have verified your email address.' ], 401); |
|
62 | 62 | } |
63 | 63 | } catch (JWTException $e) { |
64 | 64 | // something went wrong whilst attempting to encode the token |
65 | - return response()->json(['success' => false, 'error' => 'could_not_create_token'], 500); |
|
65 | + return response()->json([ 'success' => false, 'error' => 'could_not_create_token' ], 500); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | // all good so return the token |
69 | - return response()->json(['success' => true, 'result'=> $token]); |
|
69 | + return response()->json([ 'success' => true, 'result'=> $token ]); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -85,20 +85,20 @@ discard block |
||
85 | 85 | $input = request()->only('login', 'password'); |
86 | 86 | $validator = Validator::make($input, $rules); |
87 | 87 | |
88 | - if($validator->fails()) { |
|
88 | + if ($validator->fails()) { |
|
89 | 89 | $error = $validator->messages(); |
90 | - return response()->json(['success'=> false, 'error'=> $error], 400); |
|
90 | + return response()->json([ 'success'=> false, 'error'=> $error ], 400); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | // Detect if it is an email or an username |
94 | 94 | $login = request()->get('login'); |
95 | 95 | $loginFieldName = filter_var($login, FILTER_VALIDATE_EMAIL) ? 'email' : 'username'; |
96 | - request()->merge([$loginFieldName => $login]); |
|
96 | + request()->merge([ $loginFieldName => $login ]); |
|
97 | 97 | |
98 | - $credentials = request([$loginFieldName, 'password']); |
|
98 | + $credentials = request([ $loginFieldName, 'password' ]); |
|
99 | 99 | |
100 | - if (! $token = JWTAuth::attempt($credentials)) { |
|
101 | - return response()->json(['error' => 'User unauthorized'], 401); |
|
100 | + if (!$token = JWTAuth::attempt($credentials)) { |
|
101 | + return response()->json([ 'error' => 'User unauthorized' ], 401); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | return $this->respondWithToken($token); |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | { |
124 | 124 | auth()->logout(); |
125 | 125 | |
126 | - return response()->json(['message' => 'Successfully logged out']); |
|
126 | + return response()->json([ 'message' => 'Successfully logged out' ]); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | /** |
@@ -21,18 +21,18 @@ |
||
21 | 21 | $record = $this->getRecordFromRequest(); |
22 | 22 | |
23 | 23 | // Get roles already linked to the role |
24 | - $selectedRoleIds = []; |
|
24 | + $selectedRoleIds = [ ]; |
|
25 | 25 | |
26 | 26 | if ($record) { |
27 | 27 | foreach ($record->rolesOnDomain($domain) as $role) { |
28 | - $selectedRoleIds[] = $role->id; |
|
28 | + $selectedRoleIds[ ] = $role->id; |
|
29 | 29 | } |
30 | 30 | } |
31 | 31 | |
32 | 32 | // Get all domain roles |
33 | - $roles = []; |
|
33 | + $roles = [ ]; |
|
34 | 34 | foreach ($domain->roles as $role) { |
35 | - $roles[$role->id] = $role->name; |
|
35 | + $roles[ $role->id ] = $role->name; |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | // Add data to the view |
@@ -21,21 +21,21 @@ |
||
21 | 21 | $record = $this->getRecordFromRequest(); |
22 | 22 | |
23 | 23 | // Get profiles already linked to the role |
24 | - $selectedProfileIds = []; |
|
24 | + $selectedProfileIds = [ ]; |
|
25 | 25 | if ($record) { |
26 | 26 | foreach ($record->profiles as $profile) { |
27 | 27 | // Check if the profile is still in the domain |
28 | 28 | // It is just a security because $profiles (see below) is filtered on the domain |
29 | 29 | if ($profile->domain->id === $domain->id) { |
30 | - $selectedProfileIds[] = $profile->id; |
|
30 | + $selectedProfileIds[ ] = $profile->id; |
|
31 | 31 | } |
32 | 32 | } |
33 | 33 | } |
34 | 34 | |
35 | 35 | // Get all domain profiles |
36 | - $profiles = []; |
|
36 | + $profiles = [ ]; |
|
37 | 37 | foreach ($domain->profiles as $profile) { |
38 | - $profiles[$profile->id] = $profile->name; |
|
38 | + $profiles[ $profile->id ] = $profile->name; |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | // Add data to the view |
@@ -33,7 +33,7 @@ |
||
33 | 33 | $isModuleActive = $module->isActiveOnDomain($domain); |
34 | 34 | |
35 | 35 | // An user is allowed if he has the capability or if it is an admin module and the user can admin it |
36 | - $isUserAllowed = $user->hasCapabilityOnModule($capability, $domain, $module) || ($module->isAdminModule() && $user->canAdmin($domain, $module)); |
|
36 | + $isUserAllowed = $user->hasCapabilityOnModule($capability, $domain, $module) || ($module->isAdminModule() && $user->canAdmin($domain, $module)); |
|
37 | 37 | |
38 | 38 | if (!$isModuleActive) { |
39 | 39 | return abort(404); |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | */ |
14 | 14 | public function up() |
15 | 15 | { |
16 | - Schema::create($this->tablePrefix . 'relations', function (Blueprint $table) { |
|
16 | + Schema::create($this->tablePrefix.'relations', function(Blueprint $table) { |
|
17 | 17 | $table->increments('id'); |
18 | 18 | $table->unsignedInteger('relatedlist_id'); |
19 | 19 | $table->unsignedInteger('module_id'); |
@@ -25,19 +25,19 @@ discard block |
||
25 | 25 | |
26 | 26 | // Foreign keys |
27 | 27 | $table->foreign('module_id') |
28 | - ->references('id')->on($this->tablePrefix . 'modules') |
|
28 | + ->references('id')->on($this->tablePrefix.'modules') |
|
29 | 29 | ->onDelete('cascade'); |
30 | 30 | |
31 | 31 | $table->foreign('related_module_id') |
32 | - ->references('id')->on($this->tablePrefix . 'modules') |
|
32 | + ->references('id')->on($this->tablePrefix.'modules') |
|
33 | 33 | ->onDelete('cascade'); |
34 | 34 | |
35 | 35 | $table->foreign('relatedlist_id') |
36 | - ->references('id')->on($this->tablePrefix . 'relatedlists') |
|
36 | + ->references('id')->on($this->tablePrefix.'relatedlists') |
|
37 | 37 | ->onDelete('cascade'); |
38 | 38 | |
39 | 39 | // Unique keys |
40 | - $table->unique(['module_id', 'record_id', 'related_record_id', 'related_module_id', 'relatedlist_id'], 'relations_unique_key'); |
|
40 | + $table->unique([ 'module_id', 'record_id', 'related_record_id', 'related_module_id', 'relatedlist_id' ], 'relations_unique_key'); |
|
41 | 41 | }); |
42 | 42 | } |
43 | 43 | |
@@ -48,6 +48,6 @@ discard block |
||
48 | 48 | */ |
49 | 49 | public function down() |
50 | 50 | { |
51 | - Schema::dropIfExists($this->tablePrefix . 'relations'); |
|
51 | + Schema::dropIfExists($this->tablePrefix.'relations'); |
|
52 | 52 | } |
53 | 53 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | */ |
15 | 15 | public function up() |
16 | 16 | { |
17 | - Schema::create($this->tablePrefix . 'capabilities', function (Blueprint $table) { |
|
17 | + Schema::create($this->tablePrefix.'capabilities', function(Blueprint $table) { |
|
18 | 18 | $table->increments('id'); |
19 | 19 | $table->string('name'); |
20 | 20 | $table->timestamps(); |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | */ |
31 | 31 | public function down() |
32 | 32 | { |
33 | - Schema::dropIfExists($this->tablePrefix . 'capabilities'); |
|
33 | + Schema::dropIfExists($this->tablePrefix.'capabilities'); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | protected function addCapabilities() |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | */ |
14 | 14 | public function up() |
15 | 15 | { |
16 | - Schema::table('users', function (Blueprint $table) { |
|
16 | + Schema::table('users', function(Blueprint $table) { |
|
17 | 17 | $table->string('username')->after('id'); |
18 | 18 | $table->string('first_name')->after('username')->nullable(); |
19 | 19 | $table->string('phone')->after('password')->nullable(); |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | */ |
33 | 33 | public function down() |
34 | 34 | { |
35 | - Schema::table('users', function (Blueprint $table) { |
|
35 | + Schema::table('users', function(Blueprint $table) { |
|
36 | 36 | $table->renameColumn('username', 'name'); |
37 | 37 | $table->removeColumn('first_name'); |
38 | 38 | $table->removeColumn('last_name'); |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | */ |
14 | 14 | public function up() |
15 | 15 | { |
16 | - Schema::create($this->tablePrefix . 'privileges', function (Blueprint $table) { |
|
16 | + Schema::create($this->tablePrefix.'privileges', function(Blueprint $table) { |
|
17 | 17 | $table->increments('id'); |
18 | 18 | $table->unsignedInteger('domain_id'); |
19 | 19 | $table->unsignedInteger('role_id'); |
@@ -22,11 +22,11 @@ discard block |
||
22 | 22 | |
23 | 23 | // Foreign keys |
24 | 24 | $table->foreign('domain_id') |
25 | - ->references('id')->on($this->tablePrefix . 'domains') |
|
25 | + ->references('id')->on($this->tablePrefix.'domains') |
|
26 | 26 | ->onDelete('cascade'); |
27 | 27 | |
28 | 28 | $table->foreign('role_id') |
29 | - ->references('id')->on($this->tablePrefix . 'roles') |
|
29 | + ->references('id')->on($this->tablePrefix.'roles') |
|
30 | 30 | ->onDelete('cascade'); |
31 | 31 | |
32 | 32 | $table->foreign('user_id') |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | ->onDelete('cascade'); |
35 | 35 | |
36 | 36 | // Unique keys |
37 | - $table->unique(['domain_id', 'role_id', 'user_id']); |
|
37 | + $table->unique([ 'domain_id', 'role_id', 'user_id' ]); |
|
38 | 38 | }); |
39 | 39 | } |
40 | 40 | |
@@ -45,6 +45,6 @@ discard block |
||
45 | 45 | */ |
46 | 46 | public function down() |
47 | 47 | { |
48 | - Schema::dropIfExists($this->tablePrefix . 'privileges'); |
|
48 | + Schema::dropIfExists($this->tablePrefix.'privileges'); |
|
49 | 49 | } |
50 | 50 | } |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | */ |
14 | 14 | public function up() |
15 | 15 | { |
16 | - Schema::create($this->tablePrefix . 'blocks', function (Blueprint $table) { |
|
16 | + Schema::create($this->tablePrefix.'blocks', function(Blueprint $table) { |
|
17 | 17 | $table->increments('id'); |
18 | 18 | $table->unsignedInteger('module_id')->comment('Decrease queries'); |
19 | 19 | $table->unsignedInteger('tab_id'); |
@@ -25,11 +25,11 @@ discard block |
||
25 | 25 | |
26 | 26 | // Foreign keys |
27 | 27 | $table->foreign('module_id') |
28 | - ->references('id')->on($this->tablePrefix . 'modules') |
|
28 | + ->references('id')->on($this->tablePrefix.'modules') |
|
29 | 29 | ->onDelete('cascade'); |
30 | 30 | |
31 | 31 | $table->foreign('tab_id') |
32 | - ->references('id')->on($this->tablePrefix . 'tabs') |
|
32 | + ->references('id')->on($this->tablePrefix.'tabs') |
|
33 | 33 | ->onDelete('cascade'); |
34 | 34 | }); |
35 | 35 | } |
@@ -41,6 +41,6 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public function down() |
43 | 43 | { |
44 | - Schema::dropIfExists($this->tablePrefix . 'blocks'); |
|
44 | + Schema::dropIfExists($this->tablePrefix.'blocks'); |
|
45 | 45 | } |
46 | 46 | } |