Completed
Push — master ( ab2185...c08f71 )
by Sherif
01:55
created
PushNotificationDevices/Http/Requests/StorePushNotificationDevice.php 1 patch
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -6,26 +6,26 @@
 block discarded – undo
6 6
 
7 7
 class StorePushNotificationDevice extends FormRequest
8 8
 {
9
-    /**
10
-     * Determine if the user is authorized to make this request.
11
-     *
12
-     * @return bool
13
-     */
14
-    public function authorize()
15
-    {
16
-        return true;
17
-    }
9
+	/**
10
+	 * Determine if the user is authorized to make this request.
11
+	 *
12
+	 * @return bool
13
+	 */
14
+	public function authorize()
15
+	{
16
+		return true;
17
+	}
18 18
 
19
-    /**
20
-     * Get the validation rules that apply to the request.
21
-     *
22
-     * @return array
23
-     */
24
-    public function rules()
25
-    {
26
-        return [
27
-            'device_token' => 'required|string|max:255',
28
-            'user_id'      => 'required|exists:users,id'
29
-        ];
30
-    }
19
+	/**
20
+	 * Get the validation rules that apply to the request.
21
+	 *
22
+	 * @return array
23
+	 */
24
+	public function rules()
25
+	{
26
+		return [
27
+			'device_token' => 'required|string|max:255',
28
+			'user_id'      => 'required|exists:users,id'
29
+		];
30
+	}
31 31
 }
Please login to merge, or discard this patch.
src/Modules/Core/Database/Seeds/SettingsTableSeeder.php 1 patch
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -6,52 +6,52 @@
 block discarded – undo
6 6
 
7 7
 class SettingsTableSeeder extends Seeder
8 8
 {
9
-    /**
10
-     * Run the database seeds.
11
-     *
12
-     * @return void
13
-     */
14
-    public function run()
15
-    {
16
-        /**
17
-         * Insert the permissions related to settings table.
18
-         */
19
-        \DB::table('permissions')->insert(
20
-            [
21
-                /**
22
-                 * Settings model permissions.
23
-                 */
24
-                [
25
-                'name'       => 'index',
26
-                'model'      => 'setting',
27
-                'created_at' => \DB::raw('NOW()'),
28
-                'updated_at' => \DB::raw('NOW()')
29
-                ],
30
-                [
31
-                'name'       => 'show',
32
-                'model'      => 'setting',
33
-                'created_at' => \DB::raw('NOW()'),
34
-                'updated_at' => \DB::raw('NOW()')
35
-                ],
36
-                [
37
-                'name'       => 'update',
38
-                'model'      => 'setting',
39
-                'created_at' => \DB::raw('NOW()'),
40
-                'updated_at' => \DB::raw('NOW()')
41
-                ],
42
-                [
43
-                'name'       => 'destroy',
44
-                'model'      => 'setting',
45
-                'created_at' => \DB::raw('NOW()'),
46
-                'updated_at' => \DB::raw('NOW()')
47
-                ],
48
-                [
49
-                'name'       => 'saveMany',
50
-                'model'      => 'setting',
51
-                'created_at' => \DB::raw('NOW()'),
52
-                'updated_at' => \DB::raw('NOW()')
53
-                ]
54
-            ]
55
-        );
56
-    }
9
+	/**
10
+	 * Run the database seeds.
11
+	 *
12
+	 * @return void
13
+	 */
14
+	public function run()
15
+	{
16
+		/**
17
+		 * Insert the permissions related to settings table.
18
+		 */
19
+		\DB::table('permissions')->insert(
20
+			[
21
+				/**
22
+				 * Settings model permissions.
23
+				 */
24
+				[
25
+				'name'       => 'index',
26
+				'model'      => 'setting',
27
+				'created_at' => \DB::raw('NOW()'),
28
+				'updated_at' => \DB::raw('NOW()')
29
+				],
30
+				[
31
+				'name'       => 'show',
32
+				'model'      => 'setting',
33
+				'created_at' => \DB::raw('NOW()'),
34
+				'updated_at' => \DB::raw('NOW()')
35
+				],
36
+				[
37
+				'name'       => 'update',
38
+				'model'      => 'setting',
39
+				'created_at' => \DB::raw('NOW()'),
40
+				'updated_at' => \DB::raw('NOW()')
41
+				],
42
+				[
43
+				'name'       => 'destroy',
44
+				'model'      => 'setting',
45
+				'created_at' => \DB::raw('NOW()'),
46
+				'updated_at' => \DB::raw('NOW()')
47
+				],
48
+				[
49
+				'name'       => 'saveMany',
50
+				'model'      => 'setting',
51
+				'created_at' => \DB::raw('NOW()'),
52
+				'updated_at' => \DB::raw('NOW()')
53
+				]
54
+			]
55
+		);
56
+	}
57 57
 }
Please login to merge, or discard this patch.
src/Modules/Core/Http/Controllers/SettingController.php 1 patch
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -9,39 +9,39 @@
 block discarded – undo
9 9
 
10 10
 class SettingController extends BaseApiController
11 11
 {
12
-    /**
13
-     * Path of the sotre form request.
14
-     *
15
-     * @var string
16
-     */
17
-    protected $storeFormRequest = 'App\Modules\Core\Http\Requests\StoreSetting';
12
+	/**
13
+	 * Path of the sotre form request.
14
+	 *
15
+	 * @var string
16
+	 */
17
+	protected $storeFormRequest = 'App\Modules\Core\Http\Requests\StoreSetting';
18 18
 
19
-    /**
20
-     * Path of the model resource
21
-     *
22
-     * @var string
23
-     */
24
-    protected $modelResource = 'App\Modules\Core\Http\Resources\Setting';
19
+	/**
20
+	 * Path of the model resource
21
+	 *
22
+	 * @var string
23
+	 */
24
+	protected $modelResource = 'App\Modules\Core\Http\Resources\Setting';
25 25
 
26
-    /**
27
-     * Init new object.
28
-     *
29
-     * @param   SettingService $service
30
-     * @return  void
31
-     */
32
-    public function __construct(SettingService $service)
33
-    {
34
-        parent::__construct($service);
35
-    }
26
+	/**
27
+	 * Init new object.
28
+	 *
29
+	 * @param   SettingService $service
30
+	 * @return  void
31
+	 */
32
+	public function __construct(SettingService $service)
33
+	{
34
+		parent::__construct($service);
35
+	}
36 36
 
37
-    /**
38
-     * Save list of settings.
39
-     *
40
-     * @param Request $request
41
-     * @return \Illuminate\Http\Response
42
-     */
43
-    public function saveMany(Request $request)
44
-    {
45
-        return new GeneralResource($this->service->saveMany($request->all()));
46
-    }
37
+	/**
38
+	 * Save list of settings.
39
+	 *
40
+	 * @param Request $request
41
+	 * @return \Illuminate\Http\Response
42
+	 */
43
+	public function saveMany(Request $request)
44
+	{
45
+		return new GeneralResource($this->service->saveMany($request->all()));
46
+	}
47 47
 }
Please login to merge, or discard this patch.
src/Modules/Core/Http/Requests/StoreSetting.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -6,25 +6,25 @@
 block discarded – undo
6 6
 
7 7
 class StoreSetting extends FormRequest
8 8
 {
9
-    /**
10
-     * Determine if the user is authorized to make this request.
11
-     *
12
-     * @return bool
13
-     */
14
-    public function authorize()
15
-    {
16
-        return true;
17
-    }
9
+	/**
10
+	 * Determine if the user is authorized to make this request.
11
+	 *
12
+	 * @return bool
13
+	 */
14
+	public function authorize()
15
+	{
16
+		return true;
17
+	}
18 18
 
19
-    /**
20
-     * Get the validation rules that apply to the request.
21
-     *
22
-     * @return array
23
-     */
24
-    public function rules()
25
-    {
26
-        return [
27
-            'value' => 'required|string'
28
-        ];
29
-    }
19
+	/**
20
+	 * Get the validation rules that apply to the request.
21
+	 *
22
+	 * @return array
23
+	 */
24
+	public function rules()
25
+	{
26
+		return [
27
+			'value' => 'required|string'
28
+		];
29
+	}
30 30
 }
Please login to merge, or discard this patch.
src/Modules/Core/Routes/api.php 2 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -13,10 +13,10 @@
 block discarded – undo
13 13
 
14 14
 Route::group(['prefix' => 'settings'], function () {
15 15
 
16
-    Route::get('/', 'SettingController@index');
17
-    Route::get('{id}', 'SettingController@show');
18
-    Route::patch('{id}', 'SettingController@update');
19
-    Route::delete('{id}', 'SettingController@destroy');
20
-    Route::patch('{id}/restore', 'SettingController@restore');
21
-    Route::post('save/many', 'SettingController@saveMany');
16
+	Route::get('/', 'SettingController@index');
17
+	Route::get('{id}', 'SettingController@show');
18
+	Route::patch('{id}', 'SettingController@update');
19
+	Route::delete('{id}', 'SettingController@destroy');
20
+	Route::patch('{id}/restore', 'SettingController@restore');
21
+	Route::post('save/many', 'SettingController@saveMany');
22 22
 });
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
 |
12 12
 */
13 13
 
14
-Route::group(['prefix' => 'settings'], function () {
14
+Route::group(['prefix' => 'settings'], function() {
15 15
 
16 16
     Route::get('/', 'SettingController@index');
17 17
     Route::get('{id}', 'SettingController@show');
Please login to merge, or discard this patch.
src/Modules/Core/BaseClasses/BaseApiController.php 1 patch
Indentation   +95 added lines, -95 removed lines patch added patch discarded remove patch
@@ -8,109 +8,109 @@
 block discarded – undo
8 8
 
9 9
 class BaseApiController extends Controller
10 10
 {
11
-    /**
12
-     * Array of eager loaded relations.
13
-     *
14
-     * @var array
15
-     */
16
-    protected $relations;
11
+	/**
12
+	 * Array of eager loaded relations.
13
+	 *
14
+	 * @var array
15
+	 */
16
+	protected $relations;
17 17
 
18
-    /**
19
-     * @var object
20
-     */
21
-    protected $service;
18
+	/**
19
+	 * @var object
20
+	 */
21
+	protected $service;
22 22
 
23
-    /**
24
-     * Path of the model resource.
25
-     *
26
-     * @var string
27
-     */
28
-    protected $modelResource;
23
+	/**
24
+	 * Path of the model resource.
25
+	 *
26
+	 * @var string
27
+	 */
28
+	protected $modelResource;
29 29
 
30
-    /**
31
-     * Path of the sotre form request.
32
-     *
33
-     * @var string
34
-     */
35
-    protected $storeFormRequest;
30
+	/**
31
+	 * Path of the sotre form request.
32
+	 *
33
+	 * @var string
34
+	 */
35
+	protected $storeFormRequest;
36 36
 
37
-    /**
38
-     * Init new object.
39
-     *
40
-     * @param   mixed      $service
41
-     * @return  void
42
-     */
43
-    public function __construct($service)
44
-    {
45
-        $this->service = $service;
46
-    }
37
+	/**
38
+	 * Init new object.
39
+	 *
40
+	 * @param   mixed      $service
41
+	 * @return  void
42
+	 */
43
+	public function __construct($service)
44
+	{
45
+		$this->service = $service;
46
+	}
47 47
 
48
-    /**
49
-     * Fetch all records with relations from storage.
50
-     *
51
-     * @param Request $request
52
-     * @return \Illuminate\Http\Response
53
-     */
54
-    public function index(Request $request)
55
-    {
56
-        return $this->modelResource::collection($this->service->list($request->relations, $request->query(), $request->query('perPage'), $request->query('sortBy'), $request->query('desc'), $request->query('trashed')));
57
-    }
48
+	/**
49
+	 * Fetch all records with relations from storage.
50
+	 *
51
+	 * @param Request $request
52
+	 * @return \Illuminate\Http\Response
53
+	 */
54
+	public function index(Request $request)
55
+	{
56
+		return $this->modelResource::collection($this->service->list($request->relations, $request->query(), $request->query('perPage'), $request->query('sortBy'), $request->query('desc'), $request->query('trashed')));
57
+	}
58 58
 
59
-    /**
60
-     * Fetch the single object with relations from storage.
61
-     *
62
-     * @param  Request $request
63
-     * @param  integer $id Id of the requested model.
64
-     * @return \Illuminate\Http\Response
65
-     */
66
-    public function show(Request $request, $id)
67
-    {
68
-        return new $this->modelResource($this->service->find($id, $request->relations));
69
-    }
59
+	/**
60
+	 * Fetch the single object with relations from storage.
61
+	 *
62
+	 * @param  Request $request
63
+	 * @param  integer $id Id of the requested model.
64
+	 * @return \Illuminate\Http\Response
65
+	 */
66
+	public function show(Request $request, $id)
67
+	{
68
+		return new $this->modelResource($this->service->find($id, $request->relations));
69
+	}
70 70
 
71
-    /**
72
-     * Insert the given model to storage.
73
-     *
74
-     * @return \Illuminate\Http\Response
75
-     */
76
-    public function store()
77
-    {
78
-        $data = \App::make($this->storeFormRequest)->validated();
79
-        return new $this->modelResource($this->service->save($data));
80
-    }
71
+	/**
72
+	 * Insert the given model to storage.
73
+	 *
74
+	 * @return \Illuminate\Http\Response
75
+	 */
76
+	public function store()
77
+	{
78
+		$data = \App::make($this->storeFormRequest)->validated();
79
+		return new $this->modelResource($this->service->save($data));
80
+	}
81 81
 
82
-    /**
83
-     * Update the given model to storage.
84
-     *
85
-     * @param integer   $id
86
-     * @return \Illuminate\Http\Response
87
-     */
88
-    public function update($id)
89
-    {
90
-        $data = \App::make($this->storeFormRequest)->validated();
91
-        $data['id'] = $id;
92
-        return new $this->modelResource($this->service->save($data));
93
-    }
82
+	/**
83
+	 * Update the given model to storage.
84
+	 *
85
+	 * @param integer   $id
86
+	 * @return \Illuminate\Http\Response
87
+	 */
88
+	public function update($id)
89
+	{
90
+		$data = \App::make($this->storeFormRequest)->validated();
91
+		$data['id'] = $id;
92
+		return new $this->modelResource($this->service->save($data));
93
+	}
94 94
 
95
-    /**
96
-     * Delete by the given id from storage.
97
-     *
98
-     * @param  integer $id Id of the deleted model.
99
-     * @return \Illuminate\Http\Response
100
-     */
101
-    public function destroy($id)
102
-    {
103
-        return new GeneralResource($this->service->delete($id));
104
-    }
95
+	/**
96
+	 * Delete by the given id from storage.
97
+	 *
98
+	 * @param  integer $id Id of the deleted model.
99
+	 * @return \Illuminate\Http\Response
100
+	 */
101
+	public function destroy($id)
102
+	{
103
+		return new GeneralResource($this->service->delete($id));
104
+	}
105 105
 
106
-    /**
107
-     * Restore the deleted model.
108
-     *
109
-     * @param  integer $id Id of the restored model.
110
-     * @return \Illuminate\Http\Response
111
-     */
112
-    public function restore($id)
113
-    {
114
-        return new GeneralResource($this->service->restore($id));
115
-    }
106
+	/**
107
+	 * Restore the deleted model.
108
+	 *
109
+	 * @param  integer $id Id of the restored model.
110
+	 * @return \Illuminate\Http\Response
111
+	 */
112
+	public function restore($id)
113
+	{
114
+		return new GeneralResource($this->service->restore($id));
115
+	}
116 116
 }
Please login to merge, or discard this patch.
src/Modules/Roles/Http/Requests/AssignPermissions.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -6,25 +6,25 @@
 block discarded – undo
6 6
 
7 7
 class AssignPermissions extends FormRequest
8 8
 {
9
-    /**
10
-     * Determine if the user is authorized to make this request.
11
-     *
12
-     * @return bool
13
-     */
14
-    public function authorize()
15
-    {
16
-        return true;
17
-    }
9
+	/**
10
+	 * Determine if the user is authorized to make this request.
11
+	 *
12
+	 * @return bool
13
+	 */
14
+	public function authorize()
15
+	{
16
+		return true;
17
+	}
18 18
 
19
-    /**
20
-     * Get the validation rules that apply to the request.
21
-     *
22
-     * @return array
23
-     */
24
-    public function rules()
25
-    {
26
-        return [
27
-            'permission_ids' => 'required|exists:permissions,id'
28
-        ];
29
-    }
19
+	/**
20
+	 * Get the validation rules that apply to the request.
21
+	 *
22
+	 * @return array
23
+	 */
24
+	public function rules()
25
+	{
26
+		return [
27
+			'permission_ids' => 'required|exists:permissions,id'
28
+		];
29
+	}
30 30
 }
Please login to merge, or discard this patch.
src/Modules/Roles/Http/Requests/StoreRole.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -6,25 +6,25 @@
 block discarded – undo
6 6
 
7 7
 class StoreRole extends FormRequest
8 8
 {
9
-    /**
10
-     * Determine if the user is authorized to make this request.
11
-     *
12
-     * @return bool
13
-     */
14
-    public function authorize()
15
-    {
16
-        return true;
17
-    }
9
+	/**
10
+	 * Determine if the user is authorized to make this request.
11
+	 *
12
+	 * @return bool
13
+	 */
14
+	public function authorize()
15
+	{
16
+		return true;
17
+	}
18 18
 
19
-    /**
20
-     * Get the validation rules that apply to the request.
21
-     *
22
-     * @return array
23
-     */
24
-    public function rules()
25
-    {
26
-        return [
27
-            'name' => 'required|string|max:100|unique:roles,name,'.$this->get('id')
28
-        ];
29
-    }
19
+	/**
20
+	 * Get the validation rules that apply to the request.
21
+	 *
22
+	 * @return array
23
+	 */
24
+	public function rules()
25
+	{
26
+		return [
27
+			'name' => 'required|string|max:100|unique:roles,name,'.$this->get('id')
28
+		];
29
+	}
30 30
 }
Please login to merge, or discard this patch.
src/Modules/Users/Http/Controllers/UserController.php 1 patch
Indentation   +207 added lines, -207 removed lines patch added patch discarded remove patch
@@ -20,211 +20,211 @@
 block discarded – undo
20 20
 
21 21
 class UserController extends BaseApiController
22 22
 {
23
-    /**
24
-     * Path of the sotre form request.
25
-     *
26
-     * @var string
27
-     */
28
-    protected $storeFormRequest = 'App\Modules\Users\Http\Requests\StoreUser';
29
-
30
-    /**
31
-     * Path of the model resource.
32
-     *
33
-     * @var string
34
-     */
35
-    protected $modelResource = 'App\Modules\Users\Http\Resources\AclUser';
36
-
37
-    /**
38
-     * List of all route actions that the base api controller
39
-     * will skip permissions check for them.
40
-     * @var array
41
-     */
42
-    protected $skipPermissionCheck = ['account', 'logout', 'changePassword', 'saveProfile'];
43
-
44
-    /**
45
-     * List of all route actions that the base api controller
46
-     * will skip login check for them.
47
-     * @var array
48
-     */
49
-    protected $skipLoginCheck = ['login', 'loginSocial', 'register', 'sendReset', 'resetPassword', 'refreshToken', 'confirmEmail', 'resendEmailConfirmation'];
50
-
51
-    /**
52
-     * Init new object.
53
-     *
54
-     * @param   UserService $service
55
-     * @return  void
56
-     */
57
-    public function __construct(UserService $service)
58
-    {
59
-        parent::__construct($service);
60
-    }
61
-
62
-    /**
63
-     * Return the logged in user account.
64
-     *
65
-     * @param Request $request
66
-     * @return \Illuminate\Http\Response
67
-     */
68
-    public function account(Request $request)
69
-    {
70
-        return new $this->modelResource($this->service->account($request->relations));
71
-    }
72
-
73
-    /**
74
-     * Block the user.
75
-     *
76
-     * @param  integer  $id Id of the user.
77
-     * @return \Illuminate\Http\Response
78
-     */
79
-    public function block($id)
80
-    {
81
-        return new $this->modelResource($this->service->block($id));
82
-    }
83
-
84
-    /**
85
-     * Unblock the user.
86
-     *
87
-     * @param  integer  $id Id of the user.
88
-     * @return \Illuminate\Http\Response
89
-     */
90
-    public function unblock($id)
91
-    {
92
-        return new $this->modelResource($this->service->unblock($id));
93
-    }
94
-
95
-    /**
96
-     * Logout the user.
97
-     *
98
-     * @return \Illuminate\Http\Response
99
-     */
100
-    public function logout()
101
-    {
102
-        return new GeneralResource($this->service->logout());
103
-    }
104
-
105
-    /**
106
-     * Handle the registration request.
107
-     *
108
-     * @param Register $request
109
-     * @return \Illuminate\Http\Response
110
-     */
111
-    public function register(Register $request)
112
-    {
113
-        return new $this->modelResource($this->service->register($request->get('name'), $request->get('email'), $request->get('password')));
114
-    }
115
-
116
-    /**
117
-     * Handle the login request to the application.
118
-     *
119
-     * @param Login $request
120
-     * @return \Illuminate\Http\Response
121
-     */
122
-    public function login(Login $request)
123
-    {
124
-        $result = $this->service->login($request->get('email'), $request->get('password'));
125
-
126
-        return (new $this->modelResource($result['user']))->additional(['meta' => $result['tokens']]);
127
-    }
128
-
129
-    /**
130
-     * Handle the social login request the application.
131
-     *
132
-     * @param LoginSocial $request
133
-     * @return \Illuminate\Http\Response
134
-     */
135
-    public function loginSocial(LoginSocial $request)
136
-    {
137
-        $result = $this->service->loginSocial($request->get('auth_code'), $request->get('access_token'), $request->get('type'));
138
-
139
-        return (new $this->modelResource($result['user']))->additional(['meta' => $result['tokens']]);
140
-    }
141
-
142
-    /**
143
-     * Assign the given roles to the given user.
144
-     *
145
-     * @param AssignRoles $request
146
-     * @param integer     $id
147
-     * @return \Illuminate\Http\Response
148
-     */
149
-    public function assignRoles(AssignRoles $request, $id)
150
-    {
151
-        return new $this->modelResource($this->service->assignRoles($id, $request->get('role_ids')));
152
-    }
153
-
154
-    /**
155
-     * Send a reset link to the given user.
156
-     *
157
-     * @param SendReset $request
158
-     * @return \Illuminate\Http\Response
159
-     */
160
-    public function sendReset(SendReset $request)
161
-    {
162
-        return new GeneralResource($this->service->sendReset($request->get('email')));
163
-    }
164
-
165
-    /**
166
-     * Reset the given user's password.
167
-     *
168
-     * @param ResetPassword $request
169
-     * @return \Illuminate\Http\Response
170
-     */
171
-    public function resetPassword(ResetPassword $request)
172
-    {
173
-        return new GeneralResource($this->service->resetPassword($request->get('email'), $request->get('password'), $request->get('password_confirmation'), $request->get('token')));
174
-    }
175
-
176
-    /**
177
-     * Change the logged in user password.
178
-     *
179
-     * @param ChangePassword $request
180
-     * @return \Illuminate\Http\Response
181
-     */
182
-    public function changePassword(ChangePassword $request)
183
-    {
184
-        return new GeneralResource($this->service->changePassword($request->get('password'), $request->get('old_password')));
185
-    }
186
-
187
-    /**
188
-     * Confirm email using the confirmation code.
189
-     *
190
-     * @param ConfirmEmail $request
191
-     * @return \Illuminate\Http\Response
192
-     */
193
-    public function confirmEmail(ConfirmEmail $request)
194
-    {
195
-        return new GeneralResource($this->service->confirmEmail($request->only('confirmation_code')));
196
-    }
197
-
198
-    /**
199
-     * Resend the email confirmation mail.
200
-     *
201
-     * @param ResendEmailConfirmation $request
202
-     * @return \Illuminate\Http\Response
203
-     */
204
-    public function resendEmailConfirmation(ResendEmailConfirmation $request)
205
-    {
206
-        return new GeneralResource($this->service->sendConfirmationEmail($request->get('email')));
207
-    }
208
-
209
-    /**
210
-     * Refresh the expired login token.
211
-     *
212
-     * @param RefreshToken $request
213
-     * @return \Illuminate\Http\Response
214
-     */
215
-    public function refreshToken(RefreshToken $request)
216
-    {
217
-        return new GeneralResource($this->service->refreshToken($request->get('refresh_token')));
218
-    }
219
-
220
-    /**
221
-     * Save the given data to the logged in user.
222
-     *
223
-     * @param SaveProfile $request
224
-     * @return \Illuminate\Http\Response
225
-     */
226
-    public function saveProfile(SaveProfile $request)
227
-    {
228
-        return new $this->modelResource($this->service->saveProfile($request->get('name'), $request->get('email'), $request->get('profile_picture')));
229
-    }
23
+	/**
24
+	 * Path of the sotre form request.
25
+	 *
26
+	 * @var string
27
+	 */
28
+	protected $storeFormRequest = 'App\Modules\Users\Http\Requests\StoreUser';
29
+
30
+	/**
31
+	 * Path of the model resource.
32
+	 *
33
+	 * @var string
34
+	 */
35
+	protected $modelResource = 'App\Modules\Users\Http\Resources\AclUser';
36
+
37
+	/**
38
+	 * List of all route actions that the base api controller
39
+	 * will skip permissions check for them.
40
+	 * @var array
41
+	 */
42
+	protected $skipPermissionCheck = ['account', 'logout', 'changePassword', 'saveProfile'];
43
+
44
+	/**
45
+	 * List of all route actions that the base api controller
46
+	 * will skip login check for them.
47
+	 * @var array
48
+	 */
49
+	protected $skipLoginCheck = ['login', 'loginSocial', 'register', 'sendReset', 'resetPassword', 'refreshToken', 'confirmEmail', 'resendEmailConfirmation'];
50
+
51
+	/**
52
+	 * Init new object.
53
+	 *
54
+	 * @param   UserService $service
55
+	 * @return  void
56
+	 */
57
+	public function __construct(UserService $service)
58
+	{
59
+		parent::__construct($service);
60
+	}
61
+
62
+	/**
63
+	 * Return the logged in user account.
64
+	 *
65
+	 * @param Request $request
66
+	 * @return \Illuminate\Http\Response
67
+	 */
68
+	public function account(Request $request)
69
+	{
70
+		return new $this->modelResource($this->service->account($request->relations));
71
+	}
72
+
73
+	/**
74
+	 * Block the user.
75
+	 *
76
+	 * @param  integer  $id Id of the user.
77
+	 * @return \Illuminate\Http\Response
78
+	 */
79
+	public function block($id)
80
+	{
81
+		return new $this->modelResource($this->service->block($id));
82
+	}
83
+
84
+	/**
85
+	 * Unblock the user.
86
+	 *
87
+	 * @param  integer  $id Id of the user.
88
+	 * @return \Illuminate\Http\Response
89
+	 */
90
+	public function unblock($id)
91
+	{
92
+		return new $this->modelResource($this->service->unblock($id));
93
+	}
94
+
95
+	/**
96
+	 * Logout the user.
97
+	 *
98
+	 * @return \Illuminate\Http\Response
99
+	 */
100
+	public function logout()
101
+	{
102
+		return new GeneralResource($this->service->logout());
103
+	}
104
+
105
+	/**
106
+	 * Handle the registration request.
107
+	 *
108
+	 * @param Register $request
109
+	 * @return \Illuminate\Http\Response
110
+	 */
111
+	public function register(Register $request)
112
+	{
113
+		return new $this->modelResource($this->service->register($request->get('name'), $request->get('email'), $request->get('password')));
114
+	}
115
+
116
+	/**
117
+	 * Handle the login request to the application.
118
+	 *
119
+	 * @param Login $request
120
+	 * @return \Illuminate\Http\Response
121
+	 */
122
+	public function login(Login $request)
123
+	{
124
+		$result = $this->service->login($request->get('email'), $request->get('password'));
125
+
126
+		return (new $this->modelResource($result['user']))->additional(['meta' => $result['tokens']]);
127
+	}
128
+
129
+	/**
130
+	 * Handle the social login request the application.
131
+	 *
132
+	 * @param LoginSocial $request
133
+	 * @return \Illuminate\Http\Response
134
+	 */
135
+	public function loginSocial(LoginSocial $request)
136
+	{
137
+		$result = $this->service->loginSocial($request->get('auth_code'), $request->get('access_token'), $request->get('type'));
138
+
139
+		return (new $this->modelResource($result['user']))->additional(['meta' => $result['tokens']]);
140
+	}
141
+
142
+	/**
143
+	 * Assign the given roles to the given user.
144
+	 *
145
+	 * @param AssignRoles $request
146
+	 * @param integer     $id
147
+	 * @return \Illuminate\Http\Response
148
+	 */
149
+	public function assignRoles(AssignRoles $request, $id)
150
+	{
151
+		return new $this->modelResource($this->service->assignRoles($id, $request->get('role_ids')));
152
+	}
153
+
154
+	/**
155
+	 * Send a reset link to the given user.
156
+	 *
157
+	 * @param SendReset $request
158
+	 * @return \Illuminate\Http\Response
159
+	 */
160
+	public function sendReset(SendReset $request)
161
+	{
162
+		return new GeneralResource($this->service->sendReset($request->get('email')));
163
+	}
164
+
165
+	/**
166
+	 * Reset the given user's password.
167
+	 *
168
+	 * @param ResetPassword $request
169
+	 * @return \Illuminate\Http\Response
170
+	 */
171
+	public function resetPassword(ResetPassword $request)
172
+	{
173
+		return new GeneralResource($this->service->resetPassword($request->get('email'), $request->get('password'), $request->get('password_confirmation'), $request->get('token')));
174
+	}
175
+
176
+	/**
177
+	 * Change the logged in user password.
178
+	 *
179
+	 * @param ChangePassword $request
180
+	 * @return \Illuminate\Http\Response
181
+	 */
182
+	public function changePassword(ChangePassword $request)
183
+	{
184
+		return new GeneralResource($this->service->changePassword($request->get('password'), $request->get('old_password')));
185
+	}
186
+
187
+	/**
188
+	 * Confirm email using the confirmation code.
189
+	 *
190
+	 * @param ConfirmEmail $request
191
+	 * @return \Illuminate\Http\Response
192
+	 */
193
+	public function confirmEmail(ConfirmEmail $request)
194
+	{
195
+		return new GeneralResource($this->service->confirmEmail($request->only('confirmation_code')));
196
+	}
197
+
198
+	/**
199
+	 * Resend the email confirmation mail.
200
+	 *
201
+	 * @param ResendEmailConfirmation $request
202
+	 * @return \Illuminate\Http\Response
203
+	 */
204
+	public function resendEmailConfirmation(ResendEmailConfirmation $request)
205
+	{
206
+		return new GeneralResource($this->service->sendConfirmationEmail($request->get('email')));
207
+	}
208
+
209
+	/**
210
+	 * Refresh the expired login token.
211
+	 *
212
+	 * @param RefreshToken $request
213
+	 * @return \Illuminate\Http\Response
214
+	 */
215
+	public function refreshToken(RefreshToken $request)
216
+	{
217
+		return new GeneralResource($this->service->refreshToken($request->get('refresh_token')));
218
+	}
219
+
220
+	/**
221
+	 * Save the given data to the logged in user.
222
+	 *
223
+	 * @param SaveProfile $request
224
+	 * @return \Illuminate\Http\Response
225
+	 */
226
+	public function saveProfile(SaveProfile $request)
227
+	{
228
+		return new $this->modelResource($this->service->saveProfile($request->get('name'), $request->get('email'), $request->get('profile_picture')));
229
+	}
230 230
 }
Please login to merge, or discard this patch.