@@ -1,11 +1,11 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | $factory->define(App\Modules\V1\Acl\AclUser::class, function (Faker\Generator $faker) { |
4 | - return [ |
|
4 | + return [ |
|
5 | 5 | 'name' => $faker->name(), |
6 | 6 | 'email' => $faker->safeEmail(), |
7 | 7 | 'password' => bcrypt(123456), |
8 | 8 | 'created_at' => $faker->dateTimeBetween('-1 years', 'now'), |
9 | 9 | 'updated_at' => $faker->dateTimeBetween('-1 years', 'now') |
10 | - ]; |
|
10 | + ]; |
|
11 | 11 | }); |
@@ -12,23 +12,23 @@ |
||
12 | 12 | */ |
13 | 13 | public function up() |
14 | 14 | { |
15 | - Schema::create('permissions', function (Blueprint $table) { |
|
16 | - $table->increments('id'); |
|
17 | - $table->string('name',100); |
|
18 | - $table->string('model',100); |
|
19 | - $table->softDeletes(); |
|
20 | - $table->timestamps(); |
|
21 | - $table->unique(array('name', 'model')); |
|
22 | - }); |
|
23 | - Schema::create('groups_permissions', function (Blueprint $table) { |
|
24 | - $table->increments('id'); |
|
25 | - $table->integer('group_id'); |
|
26 | - $table->integer('permission_id'); |
|
27 | - $table->softDeletes(); |
|
28 | - $table->timestamps(); |
|
15 | + Schema::create('permissions', function (Blueprint $table) { |
|
16 | + $table->increments('id'); |
|
17 | + $table->string('name',100); |
|
18 | + $table->string('model',100); |
|
19 | + $table->softDeletes(); |
|
20 | + $table->timestamps(); |
|
21 | + $table->unique(array('name', 'model')); |
|
22 | + }); |
|
23 | + Schema::create('groups_permissions', function (Blueprint $table) { |
|
24 | + $table->increments('id'); |
|
25 | + $table->integer('group_id'); |
|
26 | + $table->integer('permission_id'); |
|
27 | + $table->softDeletes(); |
|
28 | + $table->timestamps(); |
|
29 | 29 | |
30 | - $table->index(['group_id']); |
|
31 | - }); |
|
30 | + $table->index(['group_id']); |
|
31 | + }); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
@@ -6,32 +6,32 @@ |
||
6 | 6 | |
7 | 7 | class CreateOauthAccessTokensTable extends Migration |
8 | 8 | { |
9 | - /** |
|
10 | - * Run the migrations. |
|
11 | - * |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function up() |
|
15 | - { |
|
16 | - Schema::create('oauth_access_tokens', function (Blueprint $table) { |
|
17 | - $table->string('id', 100)->primary(); |
|
18 | - $table->integer('user_id')->index()->nullable(); |
|
19 | - $table->integer('client_id'); |
|
20 | - $table->string('name')->nullable(); |
|
21 | - $table->text('scopes')->nullable(); |
|
22 | - $table->boolean('revoked'); |
|
23 | - $table->timestamps(); |
|
24 | - $table->dateTime('expires_at')->nullable(); |
|
25 | - }); |
|
26 | - } |
|
9 | + /** |
|
10 | + * Run the migrations. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function up() |
|
15 | + { |
|
16 | + Schema::create('oauth_access_tokens', function (Blueprint $table) { |
|
17 | + $table->string('id', 100)->primary(); |
|
18 | + $table->integer('user_id')->index()->nullable(); |
|
19 | + $table->integer('client_id'); |
|
20 | + $table->string('name')->nullable(); |
|
21 | + $table->text('scopes')->nullable(); |
|
22 | + $table->boolean('revoked'); |
|
23 | + $table->timestamps(); |
|
24 | + $table->dateTime('expires_at')->nullable(); |
|
25 | + }); |
|
26 | + } |
|
27 | 27 | |
28 | - /** |
|
29 | - * Reverse the migrations. |
|
30 | - * |
|
31 | - * @return void |
|
32 | - */ |
|
33 | - public function down() |
|
34 | - { |
|
35 | - Schema::drop('oauth_access_tokens'); |
|
36 | - } |
|
28 | + /** |
|
29 | + * Reverse the migrations. |
|
30 | + * |
|
31 | + * @return void |
|
32 | + */ |
|
33 | + public function down() |
|
34 | + { |
|
35 | + Schema::drop('oauth_access_tokens'); |
|
36 | + } |
|
37 | 37 | } |
@@ -6,27 +6,27 @@ |
||
6 | 6 | |
7 | 7 | class CreateOauthPersonalAccessClientsTable extends Migration |
8 | 8 | { |
9 | - /** |
|
10 | - * Run the migrations. |
|
11 | - * |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function up() |
|
15 | - { |
|
16 | - Schema::create('oauth_personal_access_clients', function (Blueprint $table) { |
|
17 | - $table->increments('id'); |
|
18 | - $table->integer('client_id')->index(); |
|
19 | - $table->timestamps(); |
|
20 | - }); |
|
21 | - } |
|
9 | + /** |
|
10 | + * Run the migrations. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function up() |
|
15 | + { |
|
16 | + Schema::create('oauth_personal_access_clients', function (Blueprint $table) { |
|
17 | + $table->increments('id'); |
|
18 | + $table->integer('client_id')->index(); |
|
19 | + $table->timestamps(); |
|
20 | + }); |
|
21 | + } |
|
22 | 22 | |
23 | - /** |
|
24 | - * Reverse the migrations. |
|
25 | - * |
|
26 | - * @return void |
|
27 | - */ |
|
28 | - public function down() |
|
29 | - { |
|
30 | - Schema::drop('oauth_personal_access_clients'); |
|
31 | - } |
|
23 | + /** |
|
24 | + * Reverse the migrations. |
|
25 | + * |
|
26 | + * @return void |
|
27 | + */ |
|
28 | + public function down() |
|
29 | + { |
|
30 | + Schema::drop('oauth_personal_access_clients'); |
|
31 | + } |
|
32 | 32 | } |
@@ -6,28 +6,28 @@ |
||
6 | 6 | |
7 | 7 | class CreateOauthRefreshTokensTable extends Migration |
8 | 8 | { |
9 | - /** |
|
10 | - * Run the migrations. |
|
11 | - * |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function up() |
|
15 | - { |
|
16 | - Schema::create('oauth_refresh_tokens', function (Blueprint $table) { |
|
17 | - $table->string('id', 100)->primary(); |
|
18 | - $table->string('access_token_id', 100)->index(); |
|
19 | - $table->boolean('revoked'); |
|
20 | - $table->dateTime('expires_at')->nullable(); |
|
21 | - }); |
|
22 | - } |
|
9 | + /** |
|
10 | + * Run the migrations. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function up() |
|
15 | + { |
|
16 | + Schema::create('oauth_refresh_tokens', function (Blueprint $table) { |
|
17 | + $table->string('id', 100)->primary(); |
|
18 | + $table->string('access_token_id', 100)->index(); |
|
19 | + $table->boolean('revoked'); |
|
20 | + $table->dateTime('expires_at')->nullable(); |
|
21 | + }); |
|
22 | + } |
|
23 | 23 | |
24 | - /** |
|
25 | - * Reverse the migrations. |
|
26 | - * |
|
27 | - * @return void |
|
28 | - */ |
|
29 | - public function down() |
|
30 | - { |
|
31 | - Schema::drop('oauth_refresh_tokens'); |
|
32 | - } |
|
24 | + /** |
|
25 | + * Reverse the migrations. |
|
26 | + * |
|
27 | + * @return void |
|
28 | + */ |
|
29 | + public function down() |
|
30 | + { |
|
31 | + Schema::drop('oauth_refresh_tokens'); |
|
32 | + } |
|
33 | 33 | } |
@@ -6,30 +6,30 @@ |
||
6 | 6 | |
7 | 7 | class CreateOauthAuthCodesTable extends Migration |
8 | 8 | { |
9 | - /** |
|
10 | - * Run the migrations. |
|
11 | - * |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function up() |
|
15 | - { |
|
16 | - Schema::create('oauth_auth_codes', function (Blueprint $table) { |
|
17 | - $table->string('id', 100)->primary(); |
|
18 | - $table->integer('user_id'); |
|
19 | - $table->integer('client_id'); |
|
20 | - $table->text('scopes')->nullable(); |
|
21 | - $table->boolean('revoked'); |
|
22 | - $table->dateTime('expires_at')->nullable(); |
|
23 | - }); |
|
24 | - } |
|
9 | + /** |
|
10 | + * Run the migrations. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function up() |
|
15 | + { |
|
16 | + Schema::create('oauth_auth_codes', function (Blueprint $table) { |
|
17 | + $table->string('id', 100)->primary(); |
|
18 | + $table->integer('user_id'); |
|
19 | + $table->integer('client_id'); |
|
20 | + $table->text('scopes')->nullable(); |
|
21 | + $table->boolean('revoked'); |
|
22 | + $table->dateTime('expires_at')->nullable(); |
|
23 | + }); |
|
24 | + } |
|
25 | 25 | |
26 | - /** |
|
27 | - * Reverse the migrations. |
|
28 | - * |
|
29 | - * @return void |
|
30 | - */ |
|
31 | - public function down() |
|
32 | - { |
|
33 | - Schema::drop('oauth_auth_codes'); |
|
34 | - } |
|
26 | + /** |
|
27 | + * Reverse the migrations. |
|
28 | + * |
|
29 | + * @return void |
|
30 | + */ |
|
31 | + public function down() |
|
32 | + { |
|
33 | + Schema::drop('oauth_auth_codes'); |
|
34 | + } |
|
35 | 35 | } |
@@ -2,105 +2,105 @@ |
||
2 | 2 | |
3 | 3 | class ErrorHandler |
4 | 4 | { |
5 | - public function unAuthorized() |
|
6 | - { |
|
7 | - $error = ['status' => 401, 'message' => trans('errors.unAuthorized')]; |
|
8 | - abort($error['status'], $error['message']); |
|
9 | - } |
|
10 | - |
|
11 | - public function invalidRefreshToken() |
|
12 | - { |
|
13 | - $error = ['status' => 401, 'message' => trans('errors.invalidRefreshToken')]; |
|
14 | - abort($error['status'], $error['message']); |
|
15 | - } |
|
16 | - |
|
17 | - public function noPermissions() |
|
18 | - { |
|
19 | - $error = ['status' => 403, 'message' => trans('errors.noPermissions')]; |
|
20 | - abort($error['status'], $error['message']); |
|
21 | - } |
|
22 | - |
|
23 | - public function loginFailed() |
|
24 | - { |
|
25 | - $error = ['status' => 400, 'message' => trans('errors.loginFailed')]; |
|
26 | - abort($error['status'], $error['message']); |
|
27 | - } |
|
28 | - |
|
29 | - public function noSocialEmail() |
|
30 | - { |
|
31 | - $error = ['status' => 400, 'message' => trans('errors.noSocialEmail')]; |
|
32 | - abort($error['status'], $error['message']); |
|
33 | - } |
|
34 | - |
|
35 | - public function userAlreadyRegistered() |
|
36 | - { |
|
37 | - $error = ['status' => 400, 'message' => trans('errors.userAlreadyRegistered')]; |
|
38 | - abort($error['status'], $error['message']); |
|
39 | - } |
|
40 | - |
|
41 | - public function connectionError() |
|
42 | - { |
|
43 | - $error = ['status' => 400, 'message' => trans('errors.connectionError')]; |
|
44 | - abort($error['status'], $error['message']); |
|
45 | - } |
|
46 | - |
|
47 | - public function redisNotRunning() |
|
48 | - { |
|
49 | - $error = ['status' => 400, 'message' => trans('errors.redisNotRunning')]; |
|
50 | - abort($error['status'], $error['message']); |
|
51 | - } |
|
52 | - |
|
53 | - public function dbQueryError() |
|
54 | - { |
|
55 | - $error = ['status' => 400, 'message' => trans('errors.dbQueryError')]; |
|
56 | - abort($error['status'], $error['message']); |
|
57 | - } |
|
58 | - |
|
59 | - public function cannotCreateSetting() |
|
60 | - { |
|
61 | - $error = ['status' => 400, 'message' => trans('errors.cannotCreateSetting')]; |
|
62 | - abort($error['status'], $error['message']); |
|
63 | - } |
|
64 | - |
|
65 | - public function cannotUpdateSettingKey() |
|
66 | - { |
|
67 | - $error = ['status' => 400, 'message' => trans('errors.cannotUpdateSettingKey')]; |
|
68 | - abort($error['status'], $error['message']); |
|
69 | - } |
|
70 | - |
|
71 | - public function userIsBlocked() |
|
72 | - { |
|
73 | - $error = ['status' => 403, 'message' => trans('errors.userIsBlocked')]; |
|
74 | - abort($error['status'], $error['message']); |
|
75 | - } |
|
76 | - |
|
77 | - public function invalidResetToken() |
|
78 | - { |
|
79 | - $error = ['status' => 400, 'message' => trans('errors.invalidResetToken')]; |
|
80 | - abort($error['status'], $error['message']); |
|
81 | - } |
|
82 | - |
|
83 | - public function invalidResetPassword() |
|
84 | - { |
|
85 | - $error = ['status' => 400, 'message' => trans('errors.invalidResetPassword')]; |
|
86 | - abort($error['status'], $error['message']); |
|
87 | - } |
|
88 | - |
|
89 | - public function invalidOldPassword() |
|
90 | - { |
|
91 | - $error = ['status' => 400, 'message' => trans('errors.invalidOldPassword')]; |
|
92 | - abort($error['status'], $error['message']); |
|
93 | - } |
|
94 | - |
|
95 | - public function notFound($text) |
|
96 | - { |
|
97 | - $error = ['status' => 404, 'message' => trans('errors.notFound', ['replace' => $text])]; |
|
98 | - abort($error['status'], $error['message']); |
|
99 | - } |
|
100 | - |
|
101 | - public function generalError() |
|
102 | - { |
|
103 | - $error = ['status' => 400, 'message' => trans('errors.generalError')]; |
|
104 | - abort($error['status'], $error['message']); |
|
105 | - } |
|
5 | + public function unAuthorized() |
|
6 | + { |
|
7 | + $error = ['status' => 401, 'message' => trans('errors.unAuthorized')]; |
|
8 | + abort($error['status'], $error['message']); |
|
9 | + } |
|
10 | + |
|
11 | + public function invalidRefreshToken() |
|
12 | + { |
|
13 | + $error = ['status' => 401, 'message' => trans('errors.invalidRefreshToken')]; |
|
14 | + abort($error['status'], $error['message']); |
|
15 | + } |
|
16 | + |
|
17 | + public function noPermissions() |
|
18 | + { |
|
19 | + $error = ['status' => 403, 'message' => trans('errors.noPermissions')]; |
|
20 | + abort($error['status'], $error['message']); |
|
21 | + } |
|
22 | + |
|
23 | + public function loginFailed() |
|
24 | + { |
|
25 | + $error = ['status' => 400, 'message' => trans('errors.loginFailed')]; |
|
26 | + abort($error['status'], $error['message']); |
|
27 | + } |
|
28 | + |
|
29 | + public function noSocialEmail() |
|
30 | + { |
|
31 | + $error = ['status' => 400, 'message' => trans('errors.noSocialEmail')]; |
|
32 | + abort($error['status'], $error['message']); |
|
33 | + } |
|
34 | + |
|
35 | + public function userAlreadyRegistered() |
|
36 | + { |
|
37 | + $error = ['status' => 400, 'message' => trans('errors.userAlreadyRegistered')]; |
|
38 | + abort($error['status'], $error['message']); |
|
39 | + } |
|
40 | + |
|
41 | + public function connectionError() |
|
42 | + { |
|
43 | + $error = ['status' => 400, 'message' => trans('errors.connectionError')]; |
|
44 | + abort($error['status'], $error['message']); |
|
45 | + } |
|
46 | + |
|
47 | + public function redisNotRunning() |
|
48 | + { |
|
49 | + $error = ['status' => 400, 'message' => trans('errors.redisNotRunning')]; |
|
50 | + abort($error['status'], $error['message']); |
|
51 | + } |
|
52 | + |
|
53 | + public function dbQueryError() |
|
54 | + { |
|
55 | + $error = ['status' => 400, 'message' => trans('errors.dbQueryError')]; |
|
56 | + abort($error['status'], $error['message']); |
|
57 | + } |
|
58 | + |
|
59 | + public function cannotCreateSetting() |
|
60 | + { |
|
61 | + $error = ['status' => 400, 'message' => trans('errors.cannotCreateSetting')]; |
|
62 | + abort($error['status'], $error['message']); |
|
63 | + } |
|
64 | + |
|
65 | + public function cannotUpdateSettingKey() |
|
66 | + { |
|
67 | + $error = ['status' => 400, 'message' => trans('errors.cannotUpdateSettingKey')]; |
|
68 | + abort($error['status'], $error['message']); |
|
69 | + } |
|
70 | + |
|
71 | + public function userIsBlocked() |
|
72 | + { |
|
73 | + $error = ['status' => 403, 'message' => trans('errors.userIsBlocked')]; |
|
74 | + abort($error['status'], $error['message']); |
|
75 | + } |
|
76 | + |
|
77 | + public function invalidResetToken() |
|
78 | + { |
|
79 | + $error = ['status' => 400, 'message' => trans('errors.invalidResetToken')]; |
|
80 | + abort($error['status'], $error['message']); |
|
81 | + } |
|
82 | + |
|
83 | + public function invalidResetPassword() |
|
84 | + { |
|
85 | + $error = ['status' => 400, 'message' => trans('errors.invalidResetPassword')]; |
|
86 | + abort($error['status'], $error['message']); |
|
87 | + } |
|
88 | + |
|
89 | + public function invalidOldPassword() |
|
90 | + { |
|
91 | + $error = ['status' => 400, 'message' => trans('errors.invalidOldPassword')]; |
|
92 | + abort($error['status'], $error['message']); |
|
93 | + } |
|
94 | + |
|
95 | + public function notFound($text) |
|
96 | + { |
|
97 | + $error = ['status' => 404, 'message' => trans('errors.notFound', ['replace' => $text])]; |
|
98 | + abort($error['status'], $error['message']); |
|
99 | + } |
|
100 | + |
|
101 | + public function generalError() |
|
102 | + { |
|
103 | + $error = ['status' => 400, 'message' => trans('errors.generalError')]; |
|
104 | + abort($error['status'], $error['message']); |
|
105 | + } |
|
106 | 106 | } |
107 | 107 | \ No newline at end of file |
@@ -6,20 +6,20 @@ discard block |
||
6 | 6 | |
7 | 7 | class AssignRelationsSeeder extends Seeder |
8 | 8 | { |
9 | - /** |
|
10 | - * Run the database seeds. |
|
11 | - * |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function run() |
|
15 | - { |
|
16 | - $adminGroupId = \DB::table('groups')->where('name', 'admin')->select('id')->first()->id; |
|
9 | + /** |
|
10 | + * Run the database seeds. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function run() |
|
15 | + { |
|
16 | + $adminGroupId = \DB::table('groups')->where('name', 'admin')->select('id')->first()->id; |
|
17 | 17 | |
18 | - /** |
|
19 | - * Assign the permissions to the admin group. |
|
20 | - */ |
|
21 | - \DB::table('permissions')->orderBy('created_at', 'asc')->whereIn('model', ['settings'])->each(function ($permission) use ($adminGroupId) { |
|
22 | - \DB::table('groups_permissions')->insert( |
|
18 | + /** |
|
19 | + * Assign the permissions to the admin group. |
|
20 | + */ |
|
21 | + \DB::table('permissions')->orderBy('created_at', 'asc')->whereIn('model', ['settings'])->each(function ($permission) use ($adminGroupId) { |
|
22 | + \DB::table('groups_permissions')->insert( |
|
23 | 23 | [ |
24 | 24 | 'permission_id' => $permission->id, |
25 | 25 | 'group_id' => $adminGroupId, |
@@ -27,6 +27,6 @@ discard block |
||
27 | 27 | 'updated_at' => \DB::raw('NOW()') |
28 | 28 | ] |
29 | 29 | ); |
30 | - }); |
|
31 | - } |
|
30 | + }); |
|
31 | + } |
|
32 | 32 | } |
@@ -6,15 +6,15 @@ |
||
6 | 6 | |
7 | 7 | class ClearDataSeeder extends Seeder |
8 | 8 | { |
9 | - /** |
|
10 | - * Run the database seeds. |
|
11 | - * |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function run() |
|
15 | - { |
|
16 | - $permissions = \DB::table('permissions')->whereIn('model', ['settings']); |
|
17 | - \DB::table('groups_permissions')->whereIn('permission_id', $permissions->pluck('id'))->delete(); |
|
18 | - $permissions->delete(); |
|
19 | - } |
|
9 | + /** |
|
10 | + * Run the database seeds. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function run() |
|
15 | + { |
|
16 | + $permissions = \DB::table('permissions')->whereIn('model', ['settings']); |
|
17 | + \DB::table('groups_permissions')->whereIn('permission_id', $permissions->pluck('id'))->delete(); |
|
18 | + $permissions->delete(); |
|
19 | + } |
|
20 | 20 | } |