@@ -15,12 +15,12 @@ |
||
15 | 15 | |
16 | 16 | Route::group(['prefix' => 'roles'], function () { |
17 | 17 | |
18 | - Route::get('/', 'RoleController@index'); |
|
19 | - Route::get('/{id}', 'RoleController@find'); |
|
20 | - Route::post('/', 'RoleController@insert'); |
|
21 | - Route::put('/', 'RoleController@update'); |
|
22 | - Route::delete('/{id}', 'RoleController@delete'); |
|
23 | - Route::get('list/deleted', 'RoleController@deleted'); |
|
24 | - Route::patch('restore/{id}', 'RoleController@restore'); |
|
25 | - Route::post('assign/permissions', 'RoleController@assignPermissions'); |
|
18 | + Route::get('/', 'RoleController@index'); |
|
19 | + Route::get('/{id}', 'RoleController@find'); |
|
20 | + Route::post('/', 'RoleController@insert'); |
|
21 | + Route::put('/', 'RoleController@update'); |
|
22 | + Route::delete('/{id}', 'RoleController@delete'); |
|
23 | + Route::get('list/deleted', 'RoleController@deleted'); |
|
24 | + Route::patch('restore/{id}', 'RoleController@restore'); |
|
25 | + Route::post('assign/permissions', 'RoleController@assignPermissions'); |
|
26 | 26 | }); |
@@ -5,37 +5,37 @@ |
||
5 | 5 | |
6 | 6 | class Users extends Migration |
7 | 7 | { |
8 | - /** |
|
9 | - * Run the migrations. |
|
10 | - * |
|
11 | - * @return void |
|
12 | - */ |
|
13 | - public function up() |
|
14 | - { |
|
15 | - Schema::create('users', function (Blueprint $table) { |
|
16 | - $table->increments('id'); |
|
17 | - $table->string('profile_picture', 150)->nullable(); |
|
18 | - $table->string('name', 100)->nullable(); |
|
19 | - $table->string('email')->unique(); |
|
20 | - $table->string('password', 60)->nullable(); |
|
21 | - $table->boolean('blocked')->default(0); |
|
22 | - $table->boolean('confirmed')->default(0); |
|
23 | - $table->string('confirmation_code')->nullable(); |
|
24 | - $table->string('locale', 2)->default('en'); |
|
25 | - $table->string('timezone', 50)->default('Africa/Cairo'); |
|
26 | - $table->softDeletes(); |
|
27 | - $table->rememberToken(); |
|
28 | - $table->timestamps(); |
|
29 | - }); |
|
30 | - } |
|
8 | + /** |
|
9 | + * Run the migrations. |
|
10 | + * |
|
11 | + * @return void |
|
12 | + */ |
|
13 | + public function up() |
|
14 | + { |
|
15 | + Schema::create('users', function (Blueprint $table) { |
|
16 | + $table->increments('id'); |
|
17 | + $table->string('profile_picture', 150)->nullable(); |
|
18 | + $table->string('name', 100)->nullable(); |
|
19 | + $table->string('email')->unique(); |
|
20 | + $table->string('password', 60)->nullable(); |
|
21 | + $table->boolean('blocked')->default(0); |
|
22 | + $table->boolean('confirmed')->default(0); |
|
23 | + $table->string('confirmation_code')->nullable(); |
|
24 | + $table->string('locale', 2)->default('en'); |
|
25 | + $table->string('timezone', 50)->default('Africa/Cairo'); |
|
26 | + $table->softDeletes(); |
|
27 | + $table->rememberToken(); |
|
28 | + $table->timestamps(); |
|
29 | + }); |
|
30 | + } |
|
31 | 31 | |
32 | - /** |
|
33 | - * Reverse the migrations. |
|
34 | - * |
|
35 | - * @return void |
|
36 | - */ |
|
37 | - public function down() |
|
38 | - { |
|
39 | - Schema::dropIfExists('users'); |
|
40 | - } |
|
32 | + /** |
|
33 | + * Reverse the migrations. |
|
34 | + * |
|
35 | + * @return void |
|
36 | + */ |
|
37 | + public function down() |
|
38 | + { |
|
39 | + Schema::dropIfExists('users'); |
|
40 | + } |
|
41 | 41 | } |
@@ -15,30 +15,30 @@ |
||
15 | 15 | |
16 | 16 | Route::group(['prefix' => 'users'], function () { |
17 | 17 | |
18 | - Route::get('/', 'UserController@index'); |
|
19 | - Route::get('/{id}', 'UserController@find'); |
|
20 | - Route::post('/', 'UserController@insert'); |
|
21 | - Route::put('/', 'UserController@update'); |
|
22 | - Route::delete('/{id}', 'UserController@delete'); |
|
23 | - Route::get('list/deleted', 'UserController@deleted'); |
|
24 | - Route::patch('restore/{id}', 'UserController@restore'); |
|
25 | - Route::get('block/{id}', 'UserController@block'); |
|
26 | - Route::get('unblock/{id}', 'UserController@unblock'); |
|
27 | - Route::post('assign/roles', 'UserController@assignRoles'); |
|
18 | + Route::get('/', 'UserController@index'); |
|
19 | + Route::get('/{id}', 'UserController@find'); |
|
20 | + Route::post('/', 'UserController@insert'); |
|
21 | + Route::put('/', 'UserController@update'); |
|
22 | + Route::delete('/{id}', 'UserController@delete'); |
|
23 | + Route::get('list/deleted', 'UserController@deleted'); |
|
24 | + Route::patch('restore/{id}', 'UserController@restore'); |
|
25 | + Route::get('block/{id}', 'UserController@block'); |
|
26 | + Route::get('unblock/{id}', 'UserController@unblock'); |
|
27 | + Route::post('assign/roles', 'UserController@assignRoles'); |
|
28 | 28 | |
29 | - Route::group(['prefix' => 'account'], function () { |
|
29 | + Route::group(['prefix' => 'account'], function () { |
|
30 | 30 | |
31 | - Route::get('my', 'UserController@account'); |
|
32 | - Route::get('logout', 'UserController@logout'); |
|
33 | - Route::post('refresh/token', 'UserController@refreshToken'); |
|
34 | - Route::post('save', 'UserController@saveProfile'); |
|
35 | - Route::post('register', 'UserController@register'); |
|
36 | - Route::post('login', 'UserController@login'); |
|
37 | - Route::post('login/social', 'UserController@loginSocial'); |
|
38 | - Route::post('send/reset', 'UserController@sendReset'); |
|
39 | - Route::post('reset/password', 'UserController@resetPassword'); |
|
40 | - Route::post('change/password', 'UserController@changePassword'); |
|
41 | - Route::post('confirm/email', 'UserController@confirmEmail'); |
|
42 | - Route::post('resend/email/confirmation', 'UserController@resendEmailConfirmation'); |
|
43 | - }); |
|
31 | + Route::get('my', 'UserController@account'); |
|
32 | + Route::get('logout', 'UserController@logout'); |
|
33 | + Route::post('refresh/token', 'UserController@refreshToken'); |
|
34 | + Route::post('save', 'UserController@saveProfile'); |
|
35 | + Route::post('register', 'UserController@register'); |
|
36 | + Route::post('login', 'UserController@login'); |
|
37 | + Route::post('login/social', 'UserController@loginSocial'); |
|
38 | + Route::post('send/reset', 'UserController@sendReset'); |
|
39 | + Route::post('reset/password', 'UserController@resetPassword'); |
|
40 | + Route::post('change/password', 'UserController@changePassword'); |
|
41 | + Route::post('confirm/email', 'UserController@confirmEmail'); |
|
42 | + Route::post('resend/email/confirmation', 'UserController@resendEmailConfirmation'); |
|
43 | + }); |
|
44 | 44 | }); |
@@ -8,105 +8,105 @@ |
||
8 | 8 | |
9 | 9 | class UsersTableSeeder extends Seeder |
10 | 10 | { |
11 | - /** |
|
12 | - * Run the database seeds. |
|
13 | - * |
|
14 | - * @return void |
|
15 | - */ |
|
16 | - public function run() |
|
17 | - { |
|
18 | - /** |
|
19 | - * Create Default roles. |
|
20 | - */ |
|
21 | - $role = Role::updateOrInsert([ |
|
22 | - 'name' => 'Admin', |
|
23 | - ],[ |
|
24 | - 'created_at' => \DB::raw('NOW()'), |
|
25 | - 'updated_at' => \DB::raw('NOW()') |
|
26 | - ]); |
|
11 | + /** |
|
12 | + * Run the database seeds. |
|
13 | + * |
|
14 | + * @return void |
|
15 | + */ |
|
16 | + public function run() |
|
17 | + { |
|
18 | + /** |
|
19 | + * Create Default roles. |
|
20 | + */ |
|
21 | + $role = Role::updateOrInsert([ |
|
22 | + 'name' => 'Admin', |
|
23 | + ],[ |
|
24 | + 'created_at' => \DB::raw('NOW()'), |
|
25 | + 'updated_at' => \DB::raw('NOW()') |
|
26 | + ]); |
|
27 | 27 | |
28 | - /** |
|
29 | - * Create Default user. |
|
30 | - */ |
|
31 | - AclUser::updateOrInsert([ |
|
32 | - 'email' => '[email protected]', |
|
33 | - ],[ |
|
34 | - 'name' => 'Admin', |
|
35 | - 'password' => \Hash::make('123456'), |
|
36 | - 'confirmed' => 1, |
|
37 | - 'created_at' => \DB::raw('NOW()'), |
|
38 | - 'updated_at' => \DB::raw('NOW()') |
|
39 | - ]); |
|
28 | + /** |
|
29 | + * Create Default user. |
|
30 | + */ |
|
31 | + AclUser::updateOrInsert([ |
|
32 | + 'email' => '[email protected]', |
|
33 | + ],[ |
|
34 | + 'name' => 'Admin', |
|
35 | + 'password' => \Hash::make('123456'), |
|
36 | + 'confirmed' => 1, |
|
37 | + 'created_at' => \DB::raw('NOW()'), |
|
38 | + 'updated_at' => \DB::raw('NOW()') |
|
39 | + ]); |
|
40 | 40 | |
41 | - /** |
|
42 | - * Insert the permissions related to users table. |
|
43 | - */ |
|
44 | - \DB::table('permissions')->insert( |
|
45 | - [ |
|
46 | - /** |
|
47 | - * Users model permissions. |
|
48 | - */ |
|
49 | - [ |
|
50 | - 'name' => 'index', |
|
51 | - 'model' => 'user', |
|
52 | - 'created_at' => \DB::raw('NOW()'), |
|
53 | - 'updated_at' => \DB::raw('NOW()') |
|
54 | - ], |
|
55 | - [ |
|
56 | - 'name' => 'find', |
|
57 | - 'model' => 'user', |
|
58 | - 'created_at' => \DB::raw('NOW()'), |
|
59 | - 'updated_at' => \DB::raw('NOW()') |
|
60 | - ], |
|
61 | - [ |
|
62 | - 'name' => 'insert', |
|
63 | - 'model' => 'user', |
|
64 | - 'created_at' => \DB::raw('NOW()'), |
|
65 | - 'updated_at' => \DB::raw('NOW()') |
|
66 | - ], |
|
67 | - [ |
|
68 | - 'name' => 'update', |
|
69 | - 'model' => 'user', |
|
70 | - 'created_at' => \DB::raw('NOW()'), |
|
71 | - 'updated_at' => \DB::raw('NOW()') |
|
72 | - ], |
|
73 | - [ |
|
74 | - 'name' => 'delete', |
|
75 | - 'model' => 'user', |
|
76 | - 'created_at' => \DB::raw('NOW()'), |
|
77 | - 'updated_at' => \DB::raw('NOW()') |
|
78 | - ], |
|
79 | - [ |
|
80 | - 'name' => 'deleted', |
|
81 | - 'model' => 'user', |
|
82 | - 'created_at' => \DB::raw('NOW()'), |
|
83 | - 'updated_at' => \DB::raw('NOW()') |
|
84 | - ], |
|
85 | - [ |
|
86 | - 'name' => 'restore', |
|
87 | - 'model' => 'user', |
|
88 | - 'created_at' => \DB::raw('NOW()'), |
|
89 | - 'updated_at' => \DB::raw('NOW()') |
|
90 | - ], |
|
91 | - [ |
|
92 | - 'name' => 'assignRoles', |
|
93 | - 'model' => 'user', |
|
94 | - 'created_at' => \DB::raw('NOW()'), |
|
95 | - 'updated_at' => \DB::raw('NOW()') |
|
96 | - ], |
|
97 | - [ |
|
98 | - 'name' => 'block', |
|
99 | - 'model' => 'user', |
|
100 | - 'created_at' => \DB::raw('NOW()'), |
|
101 | - 'updated_at' => \DB::raw('NOW()') |
|
102 | - ], |
|
103 | - [ |
|
104 | - 'name' => 'unblock', |
|
105 | - 'model' => 'user', |
|
106 | - 'created_at' => \DB::raw('NOW()'), |
|
107 | - 'updated_at' => \DB::raw('NOW()') |
|
108 | - ] |
|
109 | - ] |
|
110 | - ); |
|
111 | - } |
|
41 | + /** |
|
42 | + * Insert the permissions related to users table. |
|
43 | + */ |
|
44 | + \DB::table('permissions')->insert( |
|
45 | + [ |
|
46 | + /** |
|
47 | + * Users model permissions. |
|
48 | + */ |
|
49 | + [ |
|
50 | + 'name' => 'index', |
|
51 | + 'model' => 'user', |
|
52 | + 'created_at' => \DB::raw('NOW()'), |
|
53 | + 'updated_at' => \DB::raw('NOW()') |
|
54 | + ], |
|
55 | + [ |
|
56 | + 'name' => 'find', |
|
57 | + 'model' => 'user', |
|
58 | + 'created_at' => \DB::raw('NOW()'), |
|
59 | + 'updated_at' => \DB::raw('NOW()') |
|
60 | + ], |
|
61 | + [ |
|
62 | + 'name' => 'insert', |
|
63 | + 'model' => 'user', |
|
64 | + 'created_at' => \DB::raw('NOW()'), |
|
65 | + 'updated_at' => \DB::raw('NOW()') |
|
66 | + ], |
|
67 | + [ |
|
68 | + 'name' => 'update', |
|
69 | + 'model' => 'user', |
|
70 | + 'created_at' => \DB::raw('NOW()'), |
|
71 | + 'updated_at' => \DB::raw('NOW()') |
|
72 | + ], |
|
73 | + [ |
|
74 | + 'name' => 'delete', |
|
75 | + 'model' => 'user', |
|
76 | + 'created_at' => \DB::raw('NOW()'), |
|
77 | + 'updated_at' => \DB::raw('NOW()') |
|
78 | + ], |
|
79 | + [ |
|
80 | + 'name' => 'deleted', |
|
81 | + 'model' => 'user', |
|
82 | + 'created_at' => \DB::raw('NOW()'), |
|
83 | + 'updated_at' => \DB::raw('NOW()') |
|
84 | + ], |
|
85 | + [ |
|
86 | + 'name' => 'restore', |
|
87 | + 'model' => 'user', |
|
88 | + 'created_at' => \DB::raw('NOW()'), |
|
89 | + 'updated_at' => \DB::raw('NOW()') |
|
90 | + ], |
|
91 | + [ |
|
92 | + 'name' => 'assignRoles', |
|
93 | + 'model' => 'user', |
|
94 | + 'created_at' => \DB::raw('NOW()'), |
|
95 | + 'updated_at' => \DB::raw('NOW()') |
|
96 | + ], |
|
97 | + [ |
|
98 | + 'name' => 'block', |
|
99 | + 'model' => 'user', |
|
100 | + 'created_at' => \DB::raw('NOW()'), |
|
101 | + 'updated_at' => \DB::raw('NOW()') |
|
102 | + ], |
|
103 | + [ |
|
104 | + 'name' => 'unblock', |
|
105 | + 'model' => 'user', |
|
106 | + 'created_at' => \DB::raw('NOW()'), |
|
107 | + 'updated_at' => \DB::raw('NOW()') |
|
108 | + ] |
|
109 | + ] |
|
110 | + ); |
|
111 | + } |
|
112 | 112 | } |
@@ -6,27 +6,27 @@ |
||
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 | - $adminRoleId = \DB::table('roles')->where('name', 'admin')->select('id')->first()->id; |
|
9 | + /** |
|
10 | + * Run the database seeds. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function run() |
|
15 | + { |
|
16 | + $adminRoleId = \DB::table('roles')->where('name', 'admin')->select('id')->first()->id; |
|
17 | 17 | |
18 | - /** |
|
19 | - * Assign the permissions to the admin role. |
|
20 | - */ |
|
21 | - \DB::table('permissions')->orderBy('created_at', 'asc')->whereIn('model', ['user'])->each(function ($permission) use ($adminRoleId) { |
|
22 | - \DB::table('permission_role')->insert( |
|
23 | - [ |
|
24 | - 'permission_id' => $permission->id, |
|
25 | - 'role_id' => $adminRoleId, |
|
26 | - 'created_at' => \DB::raw('NOW()'), |
|
27 | - 'updated_at' => \DB::raw('NOW()') |
|
28 | - ] |
|
29 | - ); |
|
30 | - }); |
|
31 | - } |
|
18 | + /** |
|
19 | + * Assign the permissions to the admin role. |
|
20 | + */ |
|
21 | + \DB::table('permissions')->orderBy('created_at', 'asc')->whereIn('model', ['user'])->each(function ($permission) use ($adminRoleId) { |
|
22 | + \DB::table('permission_role')->insert( |
|
23 | + [ |
|
24 | + 'permission_id' => $permission->id, |
|
25 | + 'role_id' => $adminRoleId, |
|
26 | + 'created_at' => \DB::raw('NOW()'), |
|
27 | + 'updated_at' => \DB::raw('NOW()') |
|
28 | + ] |
|
29 | + ); |
|
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', ['user']); |
|
17 | - \DB::table('permission_role')->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', ['user']); |
|
17 | + \DB::table('permission_role')->whereIn('permission_id', $permissions->pluck('id'))->delete(); |
|
18 | + $permissions->delete(); |
|
19 | + } |
|
20 | 20 | } |
@@ -6,52 +6,52 @@ |
||
6 | 6 | |
7 | 7 | class UserRepository extends BaseRepository |
8 | 8 | { |
9 | - /** |
|
10 | - * Init new object. |
|
11 | - * |
|
12 | - * @param AclUser $model |
|
13 | - * @return void |
|
14 | - */ |
|
15 | - public function __construct(AclUser $model) |
|
16 | - { |
|
17 | - parent::__construct($model); |
|
18 | - } |
|
9 | + /** |
|
10 | + * Init new object. |
|
11 | + * |
|
12 | + * @param AclUser $model |
|
13 | + * @return void |
|
14 | + */ |
|
15 | + public function __construct(AclUser $model) |
|
16 | + { |
|
17 | + parent::__construct($model); |
|
18 | + } |
|
19 | 19 | |
20 | - /** |
|
21 | - * Detach all roles from the given role. |
|
22 | - * |
|
23 | - * @param mixed $role |
|
24 | - * @return object |
|
25 | - */ |
|
26 | - public function detachRoles($role) |
|
27 | - { |
|
28 | - $role = ! is_int($role) ? $role : $this->find($role); |
|
29 | - $role->roles()->detach(); |
|
30 | - } |
|
20 | + /** |
|
21 | + * Detach all roles from the given role. |
|
22 | + * |
|
23 | + * @param mixed $role |
|
24 | + * @return object |
|
25 | + */ |
|
26 | + public function detachRoles($role) |
|
27 | + { |
|
28 | + $role = ! is_int($role) ? $role : $this->find($role); |
|
29 | + $role->roles()->detach(); |
|
30 | + } |
|
31 | 31 | |
32 | - /** |
|
33 | - * Attach role ids to the given role. |
|
34 | - * |
|
35 | - * @param mixed $role |
|
36 | - * @param array $roleIds |
|
37 | - * @return object |
|
38 | - */ |
|
39 | - public function attachRoles($role, $roleIds) |
|
40 | - { |
|
41 | - $role = ! is_int($role) ? $role : $this->find($role); |
|
42 | - $role->roles()->attach($roleIds); |
|
43 | - } |
|
32 | + /** |
|
33 | + * Attach role ids to the given role. |
|
34 | + * |
|
35 | + * @param mixed $role |
|
36 | + * @param array $roleIds |
|
37 | + * @return object |
|
38 | + */ |
|
39 | + public function attachRoles($role, $roleIds) |
|
40 | + { |
|
41 | + $role = ! is_int($role) ? $role : $this->find($role); |
|
42 | + $role->roles()->attach($roleIds); |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * Count the given user the given roles. |
|
47 | - * |
|
48 | - * @param mixed $user |
|
49 | - * @param string[] $roles |
|
50 | - * @return boolean |
|
51 | - */ |
|
52 | - public function countRoles($user, $roles) |
|
53 | - { |
|
54 | - $user = ! is_int($user) ? $user : $this->find($user); |
|
55 | - return $user->roles()->whereIn('name', $roles)->count(); |
|
56 | - } |
|
45 | + /** |
|
46 | + * Count the given user the given roles. |
|
47 | + * |
|
48 | + * @param mixed $user |
|
49 | + * @param string[] $roles |
|
50 | + * @return boolean |
|
51 | + */ |
|
52 | + public function countRoles($user, $roles) |
|
53 | + { |
|
54 | + $user = ! is_int($user) ? $user : $this->find($user); |
|
55 | + return $user->roles()->whereIn('name', $roles)->count(); |
|
56 | + } |
|
57 | 57 | } |
@@ -24,225 +24,225 @@ |
||
24 | 24 | |
25 | 25 | class UserController extends BaseApiController |
26 | 26 | { |
27 | - /** |
|
28 | - * Path of the model resource |
|
29 | - * |
|
30 | - * @var string |
|
31 | - */ |
|
32 | - protected $modelResource = 'App\Modules\Users\Http\Resources\AclUser'; |
|
33 | - |
|
34 | - /** |
|
35 | - * List of all route actions that the base api controller |
|
36 | - * will skip permissions check for them. |
|
37 | - * @var array |
|
38 | - */ |
|
39 | - protected $skipPermissionCheck = ['account', 'logout', 'changePassword', 'saveProfile']; |
|
40 | - |
|
41 | - /** |
|
42 | - * List of all route actions that the base api controller |
|
43 | - * will skip login check for them. |
|
44 | - * @var array |
|
45 | - */ |
|
46 | - protected $skipLoginCheck = ['login', 'loginSocial', 'register', 'sendReset', 'resetPassword', 'refreshToken', 'confirmEmail', 'resendEmailConfirmation']; |
|
47 | - |
|
48 | - /** |
|
49 | - * Init new object. |
|
50 | - * |
|
51 | - * @param UserService $service |
|
52 | - * @return void |
|
53 | - */ |
|
54 | - public function __construct(UserService $service) |
|
55 | - { |
|
56 | - parent::__construct($service); |
|
57 | - } |
|
58 | - |
|
59 | - /** |
|
60 | - * Insert the given model to storage. |
|
61 | - * |
|
62 | - * @param InsertUser $request |
|
63 | - * @return \Illuminate\Http\Response |
|
64 | - */ |
|
65 | - public function insert(InsertUser $request) |
|
66 | - { |
|
67 | - return new $this->modelResource($this->service->save($request->all())); |
|
68 | - } |
|
69 | - |
|
70 | - /** |
|
71 | - * Update the given model to storage. |
|
72 | - * |
|
73 | - * @param UpdateUser $request |
|
74 | - * @return \Illuminate\Http\Response |
|
75 | - */ |
|
76 | - public function update(UpdateUser $request) |
|
77 | - { |
|
78 | - return new $this->modelResource($this->service->save($request->all())); |
|
79 | - } |
|
80 | - |
|
81 | - /** |
|
82 | - * Return the logged in user account. |
|
83 | - * |
|
84 | - * @param Request $request |
|
85 | - * @return \Illuminate\Http\Response |
|
86 | - */ |
|
87 | - public function account(Request $request) |
|
88 | - { |
|
89 | - return new $this->modelResource($this->service->account($request->relations)); |
|
90 | - } |
|
91 | - |
|
92 | - /** |
|
93 | - * Block the user. |
|
94 | - * |
|
95 | - * @param integer $id Id of the user. |
|
96 | - * @return \Illuminate\Http\Response |
|
97 | - */ |
|
98 | - public function block($id) |
|
99 | - { |
|
100 | - return new $this->modelResource($this->service->block($id)); |
|
101 | - } |
|
102 | - |
|
103 | - /** |
|
104 | - * Unblock the user. |
|
105 | - * |
|
106 | - * @param integer $id Id of the user. |
|
107 | - * @return \Illuminate\Http\Response |
|
108 | - */ |
|
109 | - public function unblock($id) |
|
110 | - { |
|
111 | - return new $this->modelResource($this->service->unblock($id)); |
|
112 | - } |
|
113 | - |
|
114 | - /** |
|
115 | - * Logout the user. |
|
116 | - * |
|
117 | - * @return \Illuminate\Http\Response |
|
118 | - */ |
|
119 | - public function logout() |
|
120 | - { |
|
121 | - return new GeneralResource($this->service->logout()); |
|
122 | - } |
|
123 | - |
|
124 | - /** |
|
125 | - * Handle a registration request. |
|
126 | - * |
|
127 | - * @param Register $request |
|
128 | - * @return \Illuminate\Http\Response |
|
129 | - */ |
|
130 | - public function register(Register $request) |
|
131 | - { |
|
132 | - return new $this->modelResource($this->service->register($request->get('name'), $request->get('email'), $request->get('password'))); |
|
133 | - } |
|
134 | - |
|
135 | - /** |
|
136 | - * Handle a login request to the application. |
|
137 | - * |
|
138 | - * @param Login $request |
|
139 | - * @return \Illuminate\Http\Response |
|
140 | - */ |
|
141 | - public function login(Login $request) |
|
142 | - { |
|
143 | - $result = $this->service->login($request->get('email'), $request->get('password'), $request->get('admin')); |
|
144 | - |
|
145 | - return (new $this->modelResource($result['user']))->additional(['meta' => $result['tokens']]); |
|
146 | - } |
|
147 | - |
|
148 | - /** |
|
149 | - * Handle a social login request of the none admin to the application. |
|
150 | - * |
|
151 | - * @param LoginSocial $request |
|
152 | - * @return \Illuminate\Http\Response |
|
153 | - */ |
|
154 | - public function loginSocial(LoginSocial $request) |
|
155 | - { |
|
156 | - $result = $this->service->loginSocial($request->get('auth_code'), $request->get('access_token'), $request->get('type')); |
|
157 | - |
|
158 | - return (new $this->modelResource($result['user']))->additional(['meta' => $result['tokens']]); |
|
159 | - } |
|
160 | - |
|
161 | - /** |
|
162 | - * Assign the given roles to the given user. |
|
163 | - * |
|
164 | - * @param AssignRoles $request |
|
165 | - * @return \Illuminate\Http\Response |
|
166 | - */ |
|
167 | - public function assignRoles(AssignRoles $request) |
|
168 | - { |
|
169 | - return new $this->modelResource($this->service->assignRoles($request->get('user_id'), $request->get('role_ids'))); |
|
170 | - } |
|
171 | - |
|
172 | - /** |
|
173 | - * Send a reset link to the given user. |
|
174 | - * |
|
175 | - * @param SendReset $request |
|
176 | - * @return \Illuminate\Http\Response |
|
177 | - */ |
|
178 | - public function sendReset(SendReset $request) |
|
179 | - { |
|
180 | - return new GeneralResource($this->service->sendReset($request->get('email'))); |
|
181 | - } |
|
182 | - |
|
183 | - /** |
|
184 | - * Reset the given user's password. |
|
185 | - * |
|
186 | - * @param ResetPassword $request |
|
187 | - * @return \Illuminate\Http\Response |
|
188 | - */ |
|
189 | - public function resetPassword(ResetPassword $request) |
|
190 | - { |
|
191 | - return new GeneralResource($this->service->resetPassword($request->get('email'), $request->get('password'), $request->get('password_confirmation'), $request->get('token'))); |
|
192 | - } |
|
193 | - |
|
194 | - /** |
|
195 | - * Change the logged in user password. |
|
196 | - * |
|
197 | - * @param ChangePassword $request |
|
198 | - * @return \Illuminate\Http\Response |
|
199 | - */ |
|
200 | - public function changePassword(ChangePassword $request) |
|
201 | - { |
|
202 | - return new GeneralResource($this->service->changePassword($request->get('password') , $request->get('old_password'))); |
|
203 | - } |
|
204 | - |
|
205 | - /** |
|
206 | - * Confirm email using the confirmation code. |
|
207 | - * |
|
208 | - * @param ConfirmEmail $request |
|
209 | - * @return \Illuminate\Http\Response |
|
210 | - */ |
|
211 | - public function confirmEmail(ConfirmEmail $request) |
|
212 | - { |
|
213 | - return new GeneralResource($this->service->confirmEmail($request->only('confirmation_code'))); |
|
214 | - } |
|
215 | - |
|
216 | - /** |
|
217 | - * Resend the email confirmation mail. |
|
218 | - * |
|
219 | - * @param ResendEmailConfirmation $request |
|
220 | - * @return \Illuminate\Http\Response |
|
221 | - */ |
|
222 | - public function resendEmailConfirmation(ResendEmailConfirmation $request) |
|
223 | - { |
|
224 | - return new GeneralResource($this->service->sendConfirmationEmail($request->get('email'))); |
|
225 | - } |
|
226 | - |
|
227 | - /** |
|
228 | - * Refresh the expired login token. |
|
229 | - * |
|
230 | - * @param RefreshToken $request |
|
231 | - * @return \Illuminate\Http\Response |
|
232 | - */ |
|
233 | - public function refreshToken(RefreshToken $request) |
|
234 | - { |
|
235 | - return new GeneralResource($this->service->refreshToken($request->get('refresh_token'))); |
|
236 | - } |
|
237 | - |
|
238 | - /** |
|
239 | - * Save the given data to the logged in user. |
|
240 | - * |
|
241 | - * @param SaveProfile $request |
|
242 | - * @return \Illuminate\Http\Response |
|
243 | - */ |
|
244 | - public function saveProfile(SaveProfile $request) |
|
245 | - { |
|
246 | - return new $this->modelResource($this->service->saveProfile($request->get('name'), $request->get('email'), $request->get('profile_picture'))); |
|
247 | - } |
|
27 | + /** |
|
28 | + * Path of the model resource |
|
29 | + * |
|
30 | + * @var string |
|
31 | + */ |
|
32 | + protected $modelResource = 'App\Modules\Users\Http\Resources\AclUser'; |
|
33 | + |
|
34 | + /** |
|
35 | + * List of all route actions that the base api controller |
|
36 | + * will skip permissions check for them. |
|
37 | + * @var array |
|
38 | + */ |
|
39 | + protected $skipPermissionCheck = ['account', 'logout', 'changePassword', 'saveProfile']; |
|
40 | + |
|
41 | + /** |
|
42 | + * List of all route actions that the base api controller |
|
43 | + * will skip login check for them. |
|
44 | + * @var array |
|
45 | + */ |
|
46 | + protected $skipLoginCheck = ['login', 'loginSocial', 'register', 'sendReset', 'resetPassword', 'refreshToken', 'confirmEmail', 'resendEmailConfirmation']; |
|
47 | + |
|
48 | + /** |
|
49 | + * Init new object. |
|
50 | + * |
|
51 | + * @param UserService $service |
|
52 | + * @return void |
|
53 | + */ |
|
54 | + public function __construct(UserService $service) |
|
55 | + { |
|
56 | + parent::__construct($service); |
|
57 | + } |
|
58 | + |
|
59 | + /** |
|
60 | + * Insert the given model to storage. |
|
61 | + * |
|
62 | + * @param InsertUser $request |
|
63 | + * @return \Illuminate\Http\Response |
|
64 | + */ |
|
65 | + public function insert(InsertUser $request) |
|
66 | + { |
|
67 | + return new $this->modelResource($this->service->save($request->all())); |
|
68 | + } |
|
69 | + |
|
70 | + /** |
|
71 | + * Update the given model to storage. |
|
72 | + * |
|
73 | + * @param UpdateUser $request |
|
74 | + * @return \Illuminate\Http\Response |
|
75 | + */ |
|
76 | + public function update(UpdateUser $request) |
|
77 | + { |
|
78 | + return new $this->modelResource($this->service->save($request->all())); |
|
79 | + } |
|
80 | + |
|
81 | + /** |
|
82 | + * Return the logged in user account. |
|
83 | + * |
|
84 | + * @param Request $request |
|
85 | + * @return \Illuminate\Http\Response |
|
86 | + */ |
|
87 | + public function account(Request $request) |
|
88 | + { |
|
89 | + return new $this->modelResource($this->service->account($request->relations)); |
|
90 | + } |
|
91 | + |
|
92 | + /** |
|
93 | + * Block the user. |
|
94 | + * |
|
95 | + * @param integer $id Id of the user. |
|
96 | + * @return \Illuminate\Http\Response |
|
97 | + */ |
|
98 | + public function block($id) |
|
99 | + { |
|
100 | + return new $this->modelResource($this->service->block($id)); |
|
101 | + } |
|
102 | + |
|
103 | + /** |
|
104 | + * Unblock the user. |
|
105 | + * |
|
106 | + * @param integer $id Id of the user. |
|
107 | + * @return \Illuminate\Http\Response |
|
108 | + */ |
|
109 | + public function unblock($id) |
|
110 | + { |
|
111 | + return new $this->modelResource($this->service->unblock($id)); |
|
112 | + } |
|
113 | + |
|
114 | + /** |
|
115 | + * Logout the user. |
|
116 | + * |
|
117 | + * @return \Illuminate\Http\Response |
|
118 | + */ |
|
119 | + public function logout() |
|
120 | + { |
|
121 | + return new GeneralResource($this->service->logout()); |
|
122 | + } |
|
123 | + |
|
124 | + /** |
|
125 | + * Handle a registration request. |
|
126 | + * |
|
127 | + * @param Register $request |
|
128 | + * @return \Illuminate\Http\Response |
|
129 | + */ |
|
130 | + public function register(Register $request) |
|
131 | + { |
|
132 | + return new $this->modelResource($this->service->register($request->get('name'), $request->get('email'), $request->get('password'))); |
|
133 | + } |
|
134 | + |
|
135 | + /** |
|
136 | + * Handle a login request to the application. |
|
137 | + * |
|
138 | + * @param Login $request |
|
139 | + * @return \Illuminate\Http\Response |
|
140 | + */ |
|
141 | + public function login(Login $request) |
|
142 | + { |
|
143 | + $result = $this->service->login($request->get('email'), $request->get('password'), $request->get('admin')); |
|
144 | + |
|
145 | + return (new $this->modelResource($result['user']))->additional(['meta' => $result['tokens']]); |
|
146 | + } |
|
147 | + |
|
148 | + /** |
|
149 | + * Handle a social login request of the none admin to the application. |
|
150 | + * |
|
151 | + * @param LoginSocial $request |
|
152 | + * @return \Illuminate\Http\Response |
|
153 | + */ |
|
154 | + public function loginSocial(LoginSocial $request) |
|
155 | + { |
|
156 | + $result = $this->service->loginSocial($request->get('auth_code'), $request->get('access_token'), $request->get('type')); |
|
157 | + |
|
158 | + return (new $this->modelResource($result['user']))->additional(['meta' => $result['tokens']]); |
|
159 | + } |
|
160 | + |
|
161 | + /** |
|
162 | + * Assign the given roles to the given user. |
|
163 | + * |
|
164 | + * @param AssignRoles $request |
|
165 | + * @return \Illuminate\Http\Response |
|
166 | + */ |
|
167 | + public function assignRoles(AssignRoles $request) |
|
168 | + { |
|
169 | + return new $this->modelResource($this->service->assignRoles($request->get('user_id'), $request->get('role_ids'))); |
|
170 | + } |
|
171 | + |
|
172 | + /** |
|
173 | + * Send a reset link to the given user. |
|
174 | + * |
|
175 | + * @param SendReset $request |
|
176 | + * @return \Illuminate\Http\Response |
|
177 | + */ |
|
178 | + public function sendReset(SendReset $request) |
|
179 | + { |
|
180 | + return new GeneralResource($this->service->sendReset($request->get('email'))); |
|
181 | + } |
|
182 | + |
|
183 | + /** |
|
184 | + * Reset the given user's password. |
|
185 | + * |
|
186 | + * @param ResetPassword $request |
|
187 | + * @return \Illuminate\Http\Response |
|
188 | + */ |
|
189 | + public function resetPassword(ResetPassword $request) |
|
190 | + { |
|
191 | + return new GeneralResource($this->service->resetPassword($request->get('email'), $request->get('password'), $request->get('password_confirmation'), $request->get('token'))); |
|
192 | + } |
|
193 | + |
|
194 | + /** |
|
195 | + * Change the logged in user password. |
|
196 | + * |
|
197 | + * @param ChangePassword $request |
|
198 | + * @return \Illuminate\Http\Response |
|
199 | + */ |
|
200 | + public function changePassword(ChangePassword $request) |
|
201 | + { |
|
202 | + return new GeneralResource($this->service->changePassword($request->get('password') , $request->get('old_password'))); |
|
203 | + } |
|
204 | + |
|
205 | + /** |
|
206 | + * Confirm email using the confirmation code. |
|
207 | + * |
|
208 | + * @param ConfirmEmail $request |
|
209 | + * @return \Illuminate\Http\Response |
|
210 | + */ |
|
211 | + public function confirmEmail(ConfirmEmail $request) |
|
212 | + { |
|
213 | + return new GeneralResource($this->service->confirmEmail($request->only('confirmation_code'))); |
|
214 | + } |
|
215 | + |
|
216 | + /** |
|
217 | + * Resend the email confirmation mail. |
|
218 | + * |
|
219 | + * @param ResendEmailConfirmation $request |
|
220 | + * @return \Illuminate\Http\Response |
|
221 | + */ |
|
222 | + public function resendEmailConfirmation(ResendEmailConfirmation $request) |
|
223 | + { |
|
224 | + return new GeneralResource($this->service->sendConfirmationEmail($request->get('email'))); |
|
225 | + } |
|
226 | + |
|
227 | + /** |
|
228 | + * Refresh the expired login token. |
|
229 | + * |
|
230 | + * @param RefreshToken $request |
|
231 | + * @return \Illuminate\Http\Response |
|
232 | + */ |
|
233 | + public function refreshToken(RefreshToken $request) |
|
234 | + { |
|
235 | + return new GeneralResource($this->service->refreshToken($request->get('refresh_token'))); |
|
236 | + } |
|
237 | + |
|
238 | + /** |
|
239 | + * Save the given data to the logged in user. |
|
240 | + * |
|
241 | + * @param SaveProfile $request |
|
242 | + * @return \Illuminate\Http\Response |
|
243 | + */ |
|
244 | + public function saveProfile(SaveProfile $request) |
|
245 | + { |
|
246 | + return new $this->modelResource($this->service->saveProfile($request->get('name'), $request->get('email'), $request->get('profile_picture'))); |
|
247 | + } |
|
248 | 248 | } |
@@ -8,14 +8,14 @@ |
||
8 | 8 | |
9 | 9 | class PushNotificationDeviceRepository extends BaseRepository |
10 | 10 | { |
11 | - /** |
|
12 | - * Init new object. |
|
13 | - * |
|
14 | - * @param PushNotificationDevice $model |
|
15 | - * @return void |
|
16 | - */ |
|
17 | - public function __construct(PushNotificationDevice $model) |
|
18 | - { |
|
19 | - parent::__construct($model); |
|
20 | - } |
|
11 | + /** |
|
12 | + * Init new object. |
|
13 | + * |
|
14 | + * @param PushNotificationDevice $model |
|
15 | + * @return void |
|
16 | + */ |
|
17 | + public function __construct(PushNotificationDevice $model) |
|
18 | + { |
|
19 | + parent::__construct($model); |
|
20 | + } |
|
21 | 21 | } |