Completed
Push — master ( 35b920...0f747c )
by Sherif
01:48
created
src/Modules/Users/Database/Seeds/UsersTableSeeder.php 1 patch
Indentation   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -8,82 +8,82 @@
 block discarded – undo
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
-         * Insert the permissions related to users table.
20
-         */
21
-        \DB::table('permissions')->insert(
22
-            [
23
-                /**
24
-                 * Users model permissions.
25
-                 */
26
-                [
27
-                'name'       => 'index',
28
-                'model'      => 'user',
29
-                'created_at' => \DB::raw('NOW()'),
30
-                'updated_at' => \DB::raw('NOW()')
31
-                ],
32
-                [
33
-                'name'       => 'show',
34
-                'model'      => 'user',
35
-                'created_at' => \DB::raw('NOW()'),
36
-                'updated_at' => \DB::raw('NOW()')
37
-                ],
38
-                [
39
-                'name'       => 'store',
40
-                'model'      => 'user',
41
-                'created_at' => \DB::raw('NOW()'),
42
-                'updated_at' => \DB::raw('NOW()')
43
-                ],
44
-                [
45
-                'name'       => 'update',
46
-                'model'      => 'user',
47
-                'created_at' => \DB::raw('NOW()'),
48
-                'updated_at' => \DB::raw('NOW()')
49
-                ],
50
-                [
51
-                'name'       => 'destroy',
52
-                'model'      => 'user',
53
-                'created_at' => \DB::raw('NOW()'),
54
-                'updated_at' => \DB::raw('NOW()')
55
-                ],
56
-                [
57
-                'name'       => 'deleted',
58
-                'model'      => 'user',
59
-                'created_at' => \DB::raw('NOW()'),
60
-                'updated_at' => \DB::raw('NOW()')
61
-                ],
62
-                [
63
-                'name'       => 'restore',
64
-                'model'      => 'user',
65
-                'created_at' => \DB::raw('NOW()'),
66
-                'updated_at' => \DB::raw('NOW()')
67
-                ],
68
-                [
69
-                'name'       => 'assignRoles',
70
-                'model'      => 'user',
71
-                'created_at' => \DB::raw('NOW()'),
72
-                'updated_at' => \DB::raw('NOW()')
73
-                ],
74
-                [
75
-                'name'       => 'block',
76
-                'model'      => 'user',
77
-                'created_at' => \DB::raw('NOW()'),
78
-                'updated_at' => \DB::raw('NOW()')
79
-                ],
80
-                [
81
-                'name'       => 'unblock',
82
-                'model'      => 'user',
83
-                'created_at' => \DB::raw('NOW()'),
84
-                'updated_at' => \DB::raw('NOW()')
85
-                ]
86
-            ]
87
-        );
88
-    }
11
+	/**
12
+	 * Run the database seeds.
13
+	 *
14
+	 * @return void
15
+	 */
16
+	public function run()
17
+	{
18
+		/**
19
+		 * Insert the permissions related to users table.
20
+		 */
21
+		\DB::table('permissions')->insert(
22
+			[
23
+				/**
24
+				 * Users model permissions.
25
+				 */
26
+				[
27
+				'name'       => 'index',
28
+				'model'      => 'user',
29
+				'created_at' => \DB::raw('NOW()'),
30
+				'updated_at' => \DB::raw('NOW()')
31
+				],
32
+				[
33
+				'name'       => 'show',
34
+				'model'      => 'user',
35
+				'created_at' => \DB::raw('NOW()'),
36
+				'updated_at' => \DB::raw('NOW()')
37
+				],
38
+				[
39
+				'name'       => 'store',
40
+				'model'      => 'user',
41
+				'created_at' => \DB::raw('NOW()'),
42
+				'updated_at' => \DB::raw('NOW()')
43
+				],
44
+				[
45
+				'name'       => 'update',
46
+				'model'      => 'user',
47
+				'created_at' => \DB::raw('NOW()'),
48
+				'updated_at' => \DB::raw('NOW()')
49
+				],
50
+				[
51
+				'name'       => 'destroy',
52
+				'model'      => 'user',
53
+				'created_at' => \DB::raw('NOW()'),
54
+				'updated_at' => \DB::raw('NOW()')
55
+				],
56
+				[
57
+				'name'       => 'deleted',
58
+				'model'      => 'user',
59
+				'created_at' => \DB::raw('NOW()'),
60
+				'updated_at' => \DB::raw('NOW()')
61
+				],
62
+				[
63
+				'name'       => 'restore',
64
+				'model'      => 'user',
65
+				'created_at' => \DB::raw('NOW()'),
66
+				'updated_at' => \DB::raw('NOW()')
67
+				],
68
+				[
69
+				'name'       => 'assignRoles',
70
+				'model'      => 'user',
71
+				'created_at' => \DB::raw('NOW()'),
72
+				'updated_at' => \DB::raw('NOW()')
73
+				],
74
+				[
75
+				'name'       => 'block',
76
+				'model'      => 'user',
77
+				'created_at' => \DB::raw('NOW()'),
78
+				'updated_at' => \DB::raw('NOW()')
79
+				],
80
+				[
81
+				'name'       => 'unblock',
82
+				'model'      => 'user',
83
+				'created_at' => \DB::raw('NOW()'),
84
+				'updated_at' => \DB::raw('NOW()')
85
+				]
86
+			]
87
+		);
88
+	}
89 89
 }
Please login to merge, or discard this patch.
src/Modules/Users/Config/user.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 
3 3
 return [
4 4
 
5
-    /*
5
+	/*
6 6
     |--------------------------------------------------------------------------
7 7
     | Disable Confirm Email
8 8
     |--------------------------------------------------------------------------
@@ -11,9 +11,9 @@  discard block
 block discarded – undo
11 11
     |
12 12
     */
13 13
 
14
-    'disable_confirm_email' => env('DISABLE_CONFIRM_EMAIL', true),
14
+	'disable_confirm_email' => env('DISABLE_CONFIRM_EMAIL', true),
15 15
 
16
-    /*
16
+	/*
17 17
     |--------------------------------------------------------------------------
18 18
     | Confirm Email URL
19 19
     |--------------------------------------------------------------------------
@@ -22,9 +22,9 @@  discard block
 block discarded – undo
22 22
     |
23 23
     */
24 24
    
25
-    'confrim_email_url' => env('CONFIRM_EMAIL_URL'),
25
+	'confrim_email_url' => env('CONFIRM_EMAIL_URL'),
26 26
 
27
-    /*
27
+	/*
28 28
     |--------------------------------------------------------------------------
29 29
     | Reset Password URL
30 30
     |--------------------------------------------------------------------------
@@ -33,9 +33,9 @@  discard block
 block discarded – undo
33 33
     |
34 34
     */
35 35
    
36
-    'reset_password_url' => env('RESET_PASSWORD_URL'),
36
+	'reset_password_url' => env('RESET_PASSWORD_URL'),
37 37
 
38
-    /*
38
+	/*
39 39
     |--------------------------------------------------------------------------
40 40
     | Passport Client Id
41 41
     |--------------------------------------------------------------------------
@@ -44,9 +44,9 @@  discard block
 block discarded – undo
44 44
     |
45 45
     */
46 46
    
47
-    'passport_client_id' => env('PASSWORD_CLIENT_ID'),
47
+	'passport_client_id' => env('PASSWORD_CLIENT_ID'),
48 48
 
49
-    /*
49
+	/*
50 50
     |--------------------------------------------------------------------------
51 51
     | Passport Client Secret
52 52
     |--------------------------------------------------------------------------
@@ -55,9 +55,9 @@  discard block
 block discarded – undo
55 55
     |
56 56
     */
57 57
    
58
-    'passport_client_secret' => env('PASSWORD_CLIENT_SECRET'),
58
+	'passport_client_secret' => env('PASSWORD_CLIENT_SECRET'),
59 59
 
60
-    /*
60
+	/*
61 61
     |--------------------------------------------------------------------------
62 62
     | Token Expire In
63 63
     |--------------------------------------------------------------------------
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
     |
67 67
     */
68 68
 
69
-    /*
69
+	/*
70 70
     |--------------------------------------------------------------------------
71 71
     | Social Pass
72 72
     |--------------------------------------------------------------------------
@@ -75,5 +75,5 @@  discard block
 block discarded – undo
75 75
     |
76 76
     */
77 77
 
78
-    'social_pass' => env('SOCIAL_PASS', false),
78
+	'social_pass' => env('SOCIAL_PASS', false),
79 79
 ];
Please login to merge, or discard this patch.
src/Modules/Users/Services/UserService.php 2 patches
Indentation   +361 added lines, -361 removed lines patch added patch discarded remove patch
@@ -12,367 +12,367 @@
 block discarded – undo
12 12
 
13 13
 class UserService extends BaseService
14 14
 {
15
-    /**
16
-     * @var PermissionService
17
-     */
18
-    protected $permissionService;
19
-
20
-    /**
21
-     * @var LoginProxy
22
-     */
23
-    protected $loginProxy;
24
-
25
-    /**
26
-     * @var NotificationService
27
-     */
28
-    protected $notificationService;
29
-
30
-    /**
31
-     * @var OauthClientService
32
-     */
33
-    protected $oauthClientService;
34
-
35
-    /**
36
-     * Init new object.
37
-     *
38
-     * @param   UserRepository       $repo
39
-     * @param   PermissionService    $permissionService
40
-     * @param   LoginProxy           $loginProxy
41
-     * @param   NotificationService  $notificationService
42
-     * @param   OauthClientService   $oauthClientService
43
-     * @return  void
44
-     */
45
-    public function __construct(
46
-        UserRepository $repo,
47
-        PermissionService $permissionService,
48
-        LoginProxy $loginProxy,
49
-        NotificationService $notificationService,
50
-        OauthClientService $oauthClientService
51
-    ) {
52
-        $this->permissionService   = $permissionService;
53
-        $this->loginProxy          = $loginProxy;
54
-        $this->notificationService = $notificationService;
55
-        $this->oauthClientService  = $oauthClientService;
56
-        parent::__construct($repo);
57
-    }
58
-
59
-    /**
60
-     * Return the logged in user account.
61
-     *
62
-     * @param  array   $relations
63
-     * @return boolean
64
-     */
65
-    public function account($relations = ['roles.permissions'])
66
-    {
67
-        $permissions = [];
68
-        $user        = $this->repo->find(\Auth::id(), $relations);
69
-        foreach ($user->roles as $role) {
70
-            $role->permissions->each(function ($permission) use (&$permissions) {
71
-                $permissions[$permission->repo][$permission->id] = $permission->name;
72
-            });
73
-        }
74
-        $user->permissions = $permissions;
75
-
76
-        return $user;
77
-    }
78
-
79
-    /**
80
-     * Check if the logged in user or the given user
81
-     * has the given permissions on the given model.
82
-     *
83
-     * @param  string $permissionName
84
-     * @param  string $model
85
-     * @param  mixed  $userId
86
-     * @return boolean
87
-     */
88
-    public function can($permissionName, $model, $userId = false)
89
-    {
90
-        $permission = $this->permissionService->first([
91
-            'and' => [
92
-                'model' => $model,
93
-                'name'  => $permissionName,
94
-                'roles' => [
95
-                    'op' => 'has',
96
-                    'val' => [
97
-                        'users' => [
98
-                            'op' => 'has',
99
-                            'val' => [
100
-                                'users.id' => $userId ?: \Auth::id()
101
-                            ]
102
-                        ]
103
-                    ]
104
-                ]
105
-            ]
106
-        ]);
107
-
108
-        return $permission ? true : false;
109
-    }
110
-
111
-    /**
112
-     * Check if the logged in or the given user has the given role.
113
-     *
114
-     * @param  string[] $roles
115
-     * @param  mixed    $user
116
-     * @return boolean
117
-     */
118
-    public function hasRoles($roles, $user = false)
119
-    {
120
-        return $this->repo->countRoles($user ?: \Auth::id(), $roles) ? true : false;
121
-    }
122
-
123
-    /**
124
-     * Assign the given role ids to the given user.
125
-     *
126
-     * @param  integer $userId
127
-     * @param  array   $roleIds
128
-     * @return object
129
-     */
130
-    public function assignRoles($userId, $roleIds)
131
-    {
132
-        $user = false;
133
-        \DB::transaction(function () use ($userId, $roleIds, &$user) {
134
-            $user = $this->repo->find($userId);
135
-            $this->repo->detachRoles($user);
136
-            $this->repo->attachRoles($user, $roleIds);
137
-        });
138
-
139
-        return $user;
140
-    }
141
-
142
-    /**
143
-     * Handle the login request to the application.
144
-     *
145
-     * @param  string  $email
146
-     * @param  string  $password
147
-     * @return object
148
-     */
149
-    public function login($email, $password)
150
-    {
151
-        if (! $user = $this->repo->first(['email' => $email])) {
152
-            \Errors::loginFailed();
153
-        } elseif ($user->blocked) {
154
-            \Errors::userIsBlocked();
155
-        } elseif (! config('user.disable_confirm_email') && ! $user->confirmed) {
156
-            \Errors::emailNotConfirmed();
157
-        }
158
-
159
-        return ['user' => $user, 'tokens' => $this->loginProxy->login($user->email, $password)];
160
-    }
161
-
162
-    /**
163
-     * Handle the social login request to the application.
164
-     *
165
-     * @param  string $authCode
166
-     * @param  string $accessToken
167
-     * @return array
168
-     */
169
-    public function loginSocial($authCode, $accessToken, $type)
170
-    {
171
-        $accessToken = $authCode ? Arr::get(\Socialite::driver($type)->getAccessTokenResponse($authCode), 'access_token') : $accessToken;
172
-        $user        = \Socialite::driver($type)->userFromToken($accessToken)->user;
173
-
174
-        if (! \Arr::has($user, 'email')) {
175
-            \Errors::noSocialEmail();
176
-        }
177
-
178
-        if (! $this->repo->first(['email' => $user['email']])) {
179
-            $this->register($user['name'], $user['email'], '', true);
180
-        }
181
-
182
-        return $this->login($user['email'], config('user.social_pass'));
183
-    }
184
-    /**
185
-     * Handle the registration request.
186
-     *
187
-     * @param  array   $data
188
-     * @param  boolean $skipConfirmEmail
189
-     * @param  integer $roleId
190
-     * @return object
191
-     */
192
-    public function register($data, $skipConfirmEmail = false, $roleId = false)
193
-    {
194
-        $data['confirmed'] = $skipConfirmEmail;
195
-
196
-        if($roleId){
197
-            $data ['roles'] = [['id' => $roleId]];
198
-        }
199
-
200
-        $user = $this->repo->save($data);
201
-
202
-        if (! $skipConfirmEmail && ! config('user.disable_confirm_email')) {
203
-            $this->sendConfirmationEmail($user->email);
204
-        }
205
-
206
-        return $user;
207
-    }
15
+	/**
16
+	 * @var PermissionService
17
+	 */
18
+	protected $permissionService;
19
+
20
+	/**
21
+	 * @var LoginProxy
22
+	 */
23
+	protected $loginProxy;
24
+
25
+	/**
26
+	 * @var NotificationService
27
+	 */
28
+	protected $notificationService;
29
+
30
+	/**
31
+	 * @var OauthClientService
32
+	 */
33
+	protected $oauthClientService;
34
+
35
+	/**
36
+	 * Init new object.
37
+	 *
38
+	 * @param   UserRepository       $repo
39
+	 * @param   PermissionService    $permissionService
40
+	 * @param   LoginProxy           $loginProxy
41
+	 * @param   NotificationService  $notificationService
42
+	 * @param   OauthClientService   $oauthClientService
43
+	 * @return  void
44
+	 */
45
+	public function __construct(
46
+		UserRepository $repo,
47
+		PermissionService $permissionService,
48
+		LoginProxy $loginProxy,
49
+		NotificationService $notificationService,
50
+		OauthClientService $oauthClientService
51
+	) {
52
+		$this->permissionService   = $permissionService;
53
+		$this->loginProxy          = $loginProxy;
54
+		$this->notificationService = $notificationService;
55
+		$this->oauthClientService  = $oauthClientService;
56
+		parent::__construct($repo);
57
+	}
58
+
59
+	/**
60
+	 * Return the logged in user account.
61
+	 *
62
+	 * @param  array   $relations
63
+	 * @return boolean
64
+	 */
65
+	public function account($relations = ['roles.permissions'])
66
+	{
67
+		$permissions = [];
68
+		$user        = $this->repo->find(\Auth::id(), $relations);
69
+		foreach ($user->roles as $role) {
70
+			$role->permissions->each(function ($permission) use (&$permissions) {
71
+				$permissions[$permission->repo][$permission->id] = $permission->name;
72
+			});
73
+		}
74
+		$user->permissions = $permissions;
75
+
76
+		return $user;
77
+	}
78
+
79
+	/**
80
+	 * Check if the logged in user or the given user
81
+	 * has the given permissions on the given model.
82
+	 *
83
+	 * @param  string $permissionName
84
+	 * @param  string $model
85
+	 * @param  mixed  $userId
86
+	 * @return boolean
87
+	 */
88
+	public function can($permissionName, $model, $userId = false)
89
+	{
90
+		$permission = $this->permissionService->first([
91
+			'and' => [
92
+				'model' => $model,
93
+				'name'  => $permissionName,
94
+				'roles' => [
95
+					'op' => 'has',
96
+					'val' => [
97
+						'users' => [
98
+							'op' => 'has',
99
+							'val' => [
100
+								'users.id' => $userId ?: \Auth::id()
101
+							]
102
+						]
103
+					]
104
+				]
105
+			]
106
+		]);
107
+
108
+		return $permission ? true : false;
109
+	}
110
+
111
+	/**
112
+	 * Check if the logged in or the given user has the given role.
113
+	 *
114
+	 * @param  string[] $roles
115
+	 * @param  mixed    $user
116
+	 * @return boolean
117
+	 */
118
+	public function hasRoles($roles, $user = false)
119
+	{
120
+		return $this->repo->countRoles($user ?: \Auth::id(), $roles) ? true : false;
121
+	}
122
+
123
+	/**
124
+	 * Assign the given role ids to the given user.
125
+	 *
126
+	 * @param  integer $userId
127
+	 * @param  array   $roleIds
128
+	 * @return object
129
+	 */
130
+	public function assignRoles($userId, $roleIds)
131
+	{
132
+		$user = false;
133
+		\DB::transaction(function () use ($userId, $roleIds, &$user) {
134
+			$user = $this->repo->find($userId);
135
+			$this->repo->detachRoles($user);
136
+			$this->repo->attachRoles($user, $roleIds);
137
+		});
138
+
139
+		return $user;
140
+	}
141
+
142
+	/**
143
+	 * Handle the login request to the application.
144
+	 *
145
+	 * @param  string  $email
146
+	 * @param  string  $password
147
+	 * @return object
148
+	 */
149
+	public function login($email, $password)
150
+	{
151
+		if (! $user = $this->repo->first(['email' => $email])) {
152
+			\Errors::loginFailed();
153
+		} elseif ($user->blocked) {
154
+			\Errors::userIsBlocked();
155
+		} elseif (! config('user.disable_confirm_email') && ! $user->confirmed) {
156
+			\Errors::emailNotConfirmed();
157
+		}
158
+
159
+		return ['user' => $user, 'tokens' => $this->loginProxy->login($user->email, $password)];
160
+	}
161
+
162
+	/**
163
+	 * Handle the social login request to the application.
164
+	 *
165
+	 * @param  string $authCode
166
+	 * @param  string $accessToken
167
+	 * @return array
168
+	 */
169
+	public function loginSocial($authCode, $accessToken, $type)
170
+	{
171
+		$accessToken = $authCode ? Arr::get(\Socialite::driver($type)->getAccessTokenResponse($authCode), 'access_token') : $accessToken;
172
+		$user        = \Socialite::driver($type)->userFromToken($accessToken)->user;
173
+
174
+		if (! \Arr::has($user, 'email')) {
175
+			\Errors::noSocialEmail();
176
+		}
177
+
178
+		if (! $this->repo->first(['email' => $user['email']])) {
179
+			$this->register($user['name'], $user['email'], '', true);
180
+		}
181
+
182
+		return $this->login($user['email'], config('user.social_pass'));
183
+	}
184
+	/**
185
+	 * Handle the registration request.
186
+	 *
187
+	 * @param  array   $data
188
+	 * @param  boolean $skipConfirmEmail
189
+	 * @param  integer $roleId
190
+	 * @return object
191
+	 */
192
+	public function register($data, $skipConfirmEmail = false, $roleId = false)
193
+	{
194
+		$data['confirmed'] = $skipConfirmEmail;
195
+
196
+		if($roleId){
197
+			$data ['roles'] = [['id' => $roleId]];
198
+		}
199
+
200
+		$user = $this->repo->save($data);
201
+
202
+		if (! $skipConfirmEmail && ! config('user.disable_confirm_email')) {
203
+			$this->sendConfirmationEmail($user->email);
204
+		}
205
+
206
+		return $user;
207
+	}
208 208
     
209
-    /**
210
-     * Block the user.
211
-     *
212
-     * @param  integer $userId
213
-     * @return object
214
-     */
215
-    public function block($userId)
216
-    {
217
-        if (\Auth::id() == $userId) {
218
-            \Errors::noPermissions();
219
-        }
209
+	/**
210
+	 * Block the user.
211
+	 *
212
+	 * @param  integer $userId
213
+	 * @return object
214
+	 */
215
+	public function block($userId)
216
+	{
217
+		if (\Auth::id() == $userId) {
218
+			\Errors::noPermissions();
219
+		}
220 220
         
221
-        return $this->repo->save(['id' => $userId, 'blocked' => 1]);
222
-    }
223
-
224
-    /**
225
-     * Unblock the user.
226
-     *
227
-     * @param  integer $userId
228
-     * @return object
229
-     */
230
-    public function unblock($userId)
231
-    {
232
-        return $this->repo->save(['id' => $userId, 'blocked' => 0]);
233
-    }
234
-
235
-    /**
236
-     * Send a reset link to the given user.
237
-     *
238
-     * @param  string  $email
239
-     * @return void
240
-     */
241
-    public function sendReset($email)
242
-    {
243
-        if (! $user = $this->repo->first(['email' => $email])) {
244
-            \Errors::notFound('email');
245
-        }
246
-
247
-        $token = \Password::createToken($user);
248
-        $this->notificationService->notify($user, 'ResetPassword', $token);
249
-    }
250
-
251
-    /**
252
-     * Reset the given user's password.
253
-     *
254
-     * @param   string  $email
255
-     * @param   string  $password
256
-     * @param   string  $passwordConfirmation
257
-     * @param   string  $token
258
-     * @return string|void
259
-     */
260
-    public function resetPassword($email, $password, $passwordConfirmation, $token)
261
-    {
262
-        $response = \Password::reset([
263
-            'email'                 => $email,
264
-            'password'              => $password,
265
-            'password_confirmation' => $passwordConfirmation,
266
-            'token'                 => $token
267
-        ], function ($user, $password) {
268
-            $this->repo->save(['id' => $user->id, 'password' => $password]);
269
-        });
270
-
271
-        switch ($response) {
272
-            case \Password::PASSWORD_RESET:
273
-                return 'success';
274
-                break;
275
-
276
-            case \Password::INVALID_TOKEN:
277
-                \Errors::invalidResetToken();
278
-                break;
279
-
280
-            case \Password::INVALID_PASSWORD:
281
-                \Errors::invalidResetPassword();
282
-                break;
283
-
284
-            case \Password::INVALID_USER:
285
-                \Errors::notFound('user');
286
-                break;
287
-        }
288
-    }
289
-
290
-    /**
291
-     * Change the logged in user password.
292
-     *
293
-     * @param  string  $password
294
-     * @param  string  $oldPassword
295
-     * @return void
296
-     */
297
-    public function changePassword($password, $oldPassword)
298
-    {
299
-        $user = \Auth::user();
300
-        if (! \Hash::check($oldPassword, $user->password)) {
301
-            \Errors::invalidOldPassword();
302
-        }
303
-
304
-        $this->repo->save(['id' => $user->id, 'password' => $password]);
305
-    }
306
-
307
-    /**
308
-     * Confirm email using the confirmation code.
309
-     *
310
-     * @param  string $confirmationCode
311
-     * @return void
312
-     */
313
-    public function confirmEmail($confirmationCode)
314
-    {
315
-        if (! $user = $this->repo->first(['confirmation_code' => $confirmationCode])) {
316
-            \Errors::invalidConfirmationCode();
317
-        }
318
-
319
-        $this->repo->save(['id' => $user->id, 'confirmed' => 1, 'confirmation_code' => null]);
320
-    }
321
-
322
-    /**
323
-     * Send the confirmation mail.
324
-     *
325
-     * @param  string $email
326
-     * @return void
327
-     */
328
-    public function sendConfirmationEmail($email)
329
-    {
330
-        $user = $this->repo->first(['email' => $email]);
331
-        if ($user->confirmed) {
332
-            \Errors::emailAlreadyConfirmed();
333
-        }
334
-
335
-        $this->repo->save(['id' => $user->id, 'confirmation_code' => sha1(microtime())]);
336
-        $this->notificationService->notify($user, 'ConfirmEmail');
337
-    }
338
-
339
-    /**
340
-     * Save the given data to the logged in user.
341
-     *
342
-     * @param  string $name
343
-     * @param  string $email
344
-     * @param  string $profilePicture
345
-     * @return void
346
-     */
347
-    public function saveProfile($name, $email, $profilePicture = false)
348
-    {
349
-        $data['id'] = \Auth::id();
350
-        return $this->repo->save([
351
-            'id'             => \Auth::id(),
352
-            'name'           => $name,
353
-            'email'          => $email,
354
-            'profilePicture' => $profilePicture,
355
-        ]);
356
-    }
357
-
358
-    /**
359
-     * Logs out the user, revoke access token and refresh token.
360
-     *
361
-     * @return void
362
-     */
363
-    public function logout()
364
-    {
365
-        $this->oauthClientService->revokeAccessToken(\Auth::user()->token());
366
-    }
367
-
368
-    /**
369
-     * Attempt to refresh the access token using the given refresh token.
370
-     *
371
-     * @param  string $refreshToken
372
-     * @return array
373
-     */
374
-    public function refreshToken($refreshToken)
375
-    {
376
-        return $this->loginProxy->refreshToken($refreshToken);
377
-    }
221
+		return $this->repo->save(['id' => $userId, 'blocked' => 1]);
222
+	}
223
+
224
+	/**
225
+	 * Unblock the user.
226
+	 *
227
+	 * @param  integer $userId
228
+	 * @return object
229
+	 */
230
+	public function unblock($userId)
231
+	{
232
+		return $this->repo->save(['id' => $userId, 'blocked' => 0]);
233
+	}
234
+
235
+	/**
236
+	 * Send a reset link to the given user.
237
+	 *
238
+	 * @param  string  $email
239
+	 * @return void
240
+	 */
241
+	public function sendReset($email)
242
+	{
243
+		if (! $user = $this->repo->first(['email' => $email])) {
244
+			\Errors::notFound('email');
245
+		}
246
+
247
+		$token = \Password::createToken($user);
248
+		$this->notificationService->notify($user, 'ResetPassword', $token);
249
+	}
250
+
251
+	/**
252
+	 * Reset the given user's password.
253
+	 *
254
+	 * @param   string  $email
255
+	 * @param   string  $password
256
+	 * @param   string  $passwordConfirmation
257
+	 * @param   string  $token
258
+	 * @return string|void
259
+	 */
260
+	public function resetPassword($email, $password, $passwordConfirmation, $token)
261
+	{
262
+		$response = \Password::reset([
263
+			'email'                 => $email,
264
+			'password'              => $password,
265
+			'password_confirmation' => $passwordConfirmation,
266
+			'token'                 => $token
267
+		], function ($user, $password) {
268
+			$this->repo->save(['id' => $user->id, 'password' => $password]);
269
+		});
270
+
271
+		switch ($response) {
272
+			case \Password::PASSWORD_RESET:
273
+				return 'success';
274
+				break;
275
+
276
+			case \Password::INVALID_TOKEN:
277
+				\Errors::invalidResetToken();
278
+				break;
279
+
280
+			case \Password::INVALID_PASSWORD:
281
+				\Errors::invalidResetPassword();
282
+				break;
283
+
284
+			case \Password::INVALID_USER:
285
+				\Errors::notFound('user');
286
+				break;
287
+		}
288
+	}
289
+
290
+	/**
291
+	 * Change the logged in user password.
292
+	 *
293
+	 * @param  string  $password
294
+	 * @param  string  $oldPassword
295
+	 * @return void
296
+	 */
297
+	public function changePassword($password, $oldPassword)
298
+	{
299
+		$user = \Auth::user();
300
+		if (! \Hash::check($oldPassword, $user->password)) {
301
+			\Errors::invalidOldPassword();
302
+		}
303
+
304
+		$this->repo->save(['id' => $user->id, 'password' => $password]);
305
+	}
306
+
307
+	/**
308
+	 * Confirm email using the confirmation code.
309
+	 *
310
+	 * @param  string $confirmationCode
311
+	 * @return void
312
+	 */
313
+	public function confirmEmail($confirmationCode)
314
+	{
315
+		if (! $user = $this->repo->first(['confirmation_code' => $confirmationCode])) {
316
+			\Errors::invalidConfirmationCode();
317
+		}
318
+
319
+		$this->repo->save(['id' => $user->id, 'confirmed' => 1, 'confirmation_code' => null]);
320
+	}
321
+
322
+	/**
323
+	 * Send the confirmation mail.
324
+	 *
325
+	 * @param  string $email
326
+	 * @return void
327
+	 */
328
+	public function sendConfirmationEmail($email)
329
+	{
330
+		$user = $this->repo->first(['email' => $email]);
331
+		if ($user->confirmed) {
332
+			\Errors::emailAlreadyConfirmed();
333
+		}
334
+
335
+		$this->repo->save(['id' => $user->id, 'confirmation_code' => sha1(microtime())]);
336
+		$this->notificationService->notify($user, 'ConfirmEmail');
337
+	}
338
+
339
+	/**
340
+	 * Save the given data to the logged in user.
341
+	 *
342
+	 * @param  string $name
343
+	 * @param  string $email
344
+	 * @param  string $profilePicture
345
+	 * @return void
346
+	 */
347
+	public function saveProfile($name, $email, $profilePicture = false)
348
+	{
349
+		$data['id'] = \Auth::id();
350
+		return $this->repo->save([
351
+			'id'             => \Auth::id(),
352
+			'name'           => $name,
353
+			'email'          => $email,
354
+			'profilePicture' => $profilePicture,
355
+		]);
356
+	}
357
+
358
+	/**
359
+	 * Logs out the user, revoke access token and refresh token.
360
+	 *
361
+	 * @return void
362
+	 */
363
+	public function logout()
364
+	{
365
+		$this->oauthClientService->revokeAccessToken(\Auth::user()->token());
366
+	}
367
+
368
+	/**
369
+	 * Attempt to refresh the access token using the given refresh token.
370
+	 *
371
+	 * @param  string $refreshToken
372
+	 * @return array
373
+	 */
374
+	public function refreshToken($refreshToken)
375
+	{
376
+		return $this->loginProxy->refreshToken($refreshToken);
377
+	}
378 378
 }
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
         $permissions = [];
68 68
         $user        = $this->repo->find(\Auth::id(), $relations);
69 69
         foreach ($user->roles as $role) {
70
-            $role->permissions->each(function ($permission) use (&$permissions) {
70
+            $role->permissions->each(function($permission) use (&$permissions) {
71 71
                 $permissions[$permission->repo][$permission->id] = $permission->name;
72 72
             });
73 73
         }
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
     public function assignRoles($userId, $roleIds)
131 131
     {
132 132
         $user = false;
133
-        \DB::transaction(function () use ($userId, $roleIds, &$user) {
133
+        \DB::transaction(function() use ($userId, $roleIds, &$user) {
134 134
             $user = $this->repo->find($userId);
135 135
             $this->repo->detachRoles($user);
136 136
             $this->repo->attachRoles($user, $roleIds);
@@ -148,11 +148,11 @@  discard block
 block discarded – undo
148 148
      */
149 149
     public function login($email, $password)
150 150
     {
151
-        if (! $user = $this->repo->first(['email' => $email])) {
151
+        if ( ! $user = $this->repo->first(['email' => $email])) {
152 152
             \Errors::loginFailed();
153 153
         } elseif ($user->blocked) {
154 154
             \Errors::userIsBlocked();
155
-        } elseif (! config('user.disable_confirm_email') && ! $user->confirmed) {
155
+        } elseif ( ! config('user.disable_confirm_email') && ! $user->confirmed) {
156 156
             \Errors::emailNotConfirmed();
157 157
         }
158 158
 
@@ -171,11 +171,11 @@  discard block
 block discarded – undo
171 171
         $accessToken = $authCode ? Arr::get(\Socialite::driver($type)->getAccessTokenResponse($authCode), 'access_token') : $accessToken;
172 172
         $user        = \Socialite::driver($type)->userFromToken($accessToken)->user;
173 173
 
174
-        if (! \Arr::has($user, 'email')) {
174
+        if ( ! \Arr::has($user, 'email')) {
175 175
             \Errors::noSocialEmail();
176 176
         }
177 177
 
178
-        if (! $this->repo->first(['email' => $user['email']])) {
178
+        if ( ! $this->repo->first(['email' => $user['email']])) {
179 179
             $this->register($user['name'], $user['email'], '', true);
180 180
         }
181 181
 
@@ -193,13 +193,13 @@  discard block
 block discarded – undo
193 193
     {
194 194
         $data['confirmed'] = $skipConfirmEmail;
195 195
 
196
-        if($roleId){
196
+        if ($roleId) {
197 197
             $data ['roles'] = [['id' => $roleId]];
198 198
         }
199 199
 
200 200
         $user = $this->repo->save($data);
201 201
 
202
-        if (! $skipConfirmEmail && ! config('user.disable_confirm_email')) {
202
+        if ( ! $skipConfirmEmail && ! config('user.disable_confirm_email')) {
203 203
             $this->sendConfirmationEmail($user->email);
204 204
         }
205 205
 
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
      */
241 241
     public function sendReset($email)
242 242
     {
243
-        if (! $user = $this->repo->first(['email' => $email])) {
243
+        if ( ! $user = $this->repo->first(['email' => $email])) {
244 244
             \Errors::notFound('email');
245 245
         }
246 246
 
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
             'password'              => $password,
265 265
             'password_confirmation' => $passwordConfirmation,
266 266
             'token'                 => $token
267
-        ], function ($user, $password) {
267
+        ], function($user, $password) {
268 268
             $this->repo->save(['id' => $user->id, 'password' => $password]);
269 269
         });
270 270
 
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
     public function changePassword($password, $oldPassword)
298 298
     {
299 299
         $user = \Auth::user();
300
-        if (! \Hash::check($oldPassword, $user->password)) {
300
+        if ( ! \Hash::check($oldPassword, $user->password)) {
301 301
             \Errors::invalidOldPassword();
302 302
         }
303 303
 
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
      */
313 313
     public function confirmEmail($confirmationCode)
314 314
     {
315
-        if (! $user = $this->repo->first(['confirmation_code' => $confirmationCode])) {
315
+        if ( ! $user = $this->repo->first(['confirmation_code' => $confirmationCode])) {
316 316
             \Errors::invalidConfirmationCode();
317 317
         }
318 318
 
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->validated()));
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->validated()));
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.
src/Modules/Roles/Database/Seeds/RolesTableSeeder.php 2 patches
Indentation   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -8,103 +8,103 @@
 block discarded – undo
8 8
 
9 9
 class RolesTableSeeder 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::updateOrInsert([
22
-            'name' => RoleEnum::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::updateOrInsert([
22
+			'name' => RoleEnum::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
-         * Assign default users to admin roles.
43
-         */
44
-        $adminRoleId = Role::where('name', RoleEnum::ADMIN)->select('id')->first()->id;;
45
-        $adminUserId = AclUser::where('email', '[email protected]')->select('id')->first()->id;
46
-        \DB::table('role_user')->updateOrInsert([
47
-            'user_id' => $adminUserId,
48
-            'role_id' => $adminRoleId,
49
-        ],[]);
41
+		/**
42
+		 * Assign default users to admin roles.
43
+		 */
44
+		$adminRoleId = Role::where('name', RoleEnum::ADMIN)->select('id')->first()->id;;
45
+		$adminUserId = AclUser::where('email', '[email protected]')->select('id')->first()->id;
46
+		\DB::table('role_user')->updateOrInsert([
47
+			'user_id' => $adminUserId,
48
+			'role_id' => $adminRoleId,
49
+		],[]);
50 50
 
51
-        /**
52
-         * Insert the permissions related to roles table.
53
-         */
54
-        \DB::table('permissions')->insert(
55
-            [
56
-                /**
57
-                 * Roles model permissions.
58
-                 */
59
-                [
60
-                'name'       => 'index',
61
-                'model'      => 'role',
62
-                'created_at' => \DB::raw('NOW()'),
63
-                'updated_at' => \DB::raw('NOW()')
64
-                ],
65
-                [
66
-                'name'       => 'show',
67
-                'model'      => 'role',
68
-                'created_at' => \DB::raw('NOW()'),
69
-                'updated_at' => \DB::raw('NOW()')
70
-                ],
71
-                [
72
-                'name'       => 'store',
73
-                'model'      => 'role',
74
-                'created_at' => \DB::raw('NOW()'),
75
-                'updated_at' => \DB::raw('NOW()')
76
-                ],
77
-                [
78
-                'name'       => 'update',
79
-                'model'      => 'role',
80
-                'created_at' => \DB::raw('NOW()'),
81
-                'updated_at' => \DB::raw('NOW()')
82
-                ],
83
-                [
84
-                'name'       => 'destroy',
85
-                'model'      => 'role',
86
-                'created_at' => \DB::raw('NOW()'),
87
-                'updated_at' => \DB::raw('NOW()')
88
-                ],
89
-                [
90
-                'name'       => 'deleted',
91
-                'model'      => 'role',
92
-                'created_at' => \DB::raw('NOW()'),
93
-                'updated_at' => \DB::raw('NOW()')
94
-                ],
95
-                [
96
-                'name'       => 'restore',
97
-                'model'      => 'role',
98
-                'created_at' => \DB::raw('NOW()'),
99
-                'updated_at' => \DB::raw('NOW()')
100
-                ],
101
-                [
102
-                'name'       => 'assignPermissions',
103
-                'model'      => 'role',
104
-                'created_at' => \DB::raw('NOW()'),
105
-                'updated_at' => \DB::raw('NOW()')
106
-                ],
107
-            ]
108
-        );
109
-    }
51
+		/**
52
+		 * Insert the permissions related to roles table.
53
+		 */
54
+		\DB::table('permissions')->insert(
55
+			[
56
+				/**
57
+				 * Roles model permissions.
58
+				 */
59
+				[
60
+				'name'       => 'index',
61
+				'model'      => 'role',
62
+				'created_at' => \DB::raw('NOW()'),
63
+				'updated_at' => \DB::raw('NOW()')
64
+				],
65
+				[
66
+				'name'       => 'show',
67
+				'model'      => 'role',
68
+				'created_at' => \DB::raw('NOW()'),
69
+				'updated_at' => \DB::raw('NOW()')
70
+				],
71
+				[
72
+				'name'       => 'store',
73
+				'model'      => 'role',
74
+				'created_at' => \DB::raw('NOW()'),
75
+				'updated_at' => \DB::raw('NOW()')
76
+				],
77
+				[
78
+				'name'       => 'update',
79
+				'model'      => 'role',
80
+				'created_at' => \DB::raw('NOW()'),
81
+				'updated_at' => \DB::raw('NOW()')
82
+				],
83
+				[
84
+				'name'       => 'destroy',
85
+				'model'      => 'role',
86
+				'created_at' => \DB::raw('NOW()'),
87
+				'updated_at' => \DB::raw('NOW()')
88
+				],
89
+				[
90
+				'name'       => 'deleted',
91
+				'model'      => 'role',
92
+				'created_at' => \DB::raw('NOW()'),
93
+				'updated_at' => \DB::raw('NOW()')
94
+				],
95
+				[
96
+				'name'       => 'restore',
97
+				'model'      => 'role',
98
+				'created_at' => \DB::raw('NOW()'),
99
+				'updated_at' => \DB::raw('NOW()')
100
+				],
101
+				[
102
+				'name'       => 'assignPermissions',
103
+				'model'      => 'role',
104
+				'created_at' => \DB::raw('NOW()'),
105
+				'updated_at' => \DB::raw('NOW()')
106
+				],
107
+			]
108
+		);
109
+	}
110 110
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
          */
21 21
         Role::updateOrInsert([
22 22
             'name' => RoleEnum::ADMIN,
23
-        ],[
23
+        ], [
24 24
             'created_at' => \DB::raw('NOW()'),
25 25
             'updated_at' => \DB::raw('NOW()')
26 26
         ]);
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
          */
31 31
         AclUser::updateOrInsert([
32 32
             'email' => '[email protected]',
33
-        ],[
33
+        ], [
34 34
             'name'       => 'Admin',
35 35
             'password'   => \Hash::make('123456'),
36 36
             'confirmed'  => 1,
@@ -41,12 +41,12 @@  discard block
 block discarded – undo
41 41
         /**
42 42
          * Assign default users to admin roles.
43 43
          */
44
-        $adminRoleId = Role::where('name', RoleEnum::ADMIN)->select('id')->first()->id;;
44
+        $adminRoleId = Role::where('name', RoleEnum::ADMIN)->select('id')->first()->id; ;
45 45
         $adminUserId = AclUser::where('email', '[email protected]')->select('id')->first()->id;
46 46
         \DB::table('role_user')->updateOrInsert([
47 47
             'user_id' => $adminUserId,
48 48
             'role_id' => $adminRoleId,
49
-        ],[]);
49
+        ], []);
50 50
 
51 51
         /**
52 52
          * Insert the permissions related to roles table.
Please login to merge, or discard this patch.
src/Modules/Roles/ModelObservers/RoleObserver.php 1 patch
Indentation   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -7,69 +7,69 @@
 block discarded – undo
7 7
  */
8 8
 class RoleObserver
9 9
 {
10
-    public function saving($model)
11
-    {
12
-        //
13
-    }
10
+	public function saving($model)
11
+	{
12
+		//
13
+	}
14 14
 
15
-    public function saved($model)
16
-    {
17
-        //
18
-    }
15
+	public function saved($model)
16
+	{
17
+		//
18
+	}
19 19
 
20
-    public function creating($model)
21
-    {
22
-        //
23
-    }
20
+	public function creating($model)
21
+	{
22
+		//
23
+	}
24 24
 
25
-    public function created($model)
26
-    {
27
-        //
28
-    }
25
+	public function created($model)
26
+	{
27
+		//
28
+	}
29 29
 
30
-    /**
31
-     * Prevent updating of the admin role.
32
-     *
33
-     * @param  object $model the model beign updated.
34
-     * @return void
35
-     */
36
-    public function updating($model)
37
-    {
38
-        if ($model->getOriginal('name') == RoleEnum::ADMIN) {
39
-            \Errors::noPermissions();
40
-        }
41
-    }
30
+	/**
31
+	 * Prevent updating of the admin role.
32
+	 *
33
+	 * @param  object $model the model beign updated.
34
+	 * @return void
35
+	 */
36
+	public function updating($model)
37
+	{
38
+		if ($model->getOriginal('name') == RoleEnum::ADMIN) {
39
+			\Errors::noPermissions();
40
+		}
41
+	}
42 42
 
43
-    public function updated($model)
44
-    {
45
-        //
46
-    }
43
+	public function updated($model)
44
+	{
45
+		//
46
+	}
47 47
 
48
-    /**
49
-     * Prevent deleting the admin role.
50
-     *
51
-     * @param  object $model the delted model.
52
-     * @return void
53
-     */
54
-    public function deleting($model)
55
-    {
56
-        if ($model->getOriginal('name') == RoleEnum::ADMIN) {
57
-            \Errors::noPermissions();
58
-        }
59
-    }
48
+	/**
49
+	 * Prevent deleting the admin role.
50
+	 *
51
+	 * @param  object $model the delted model.
52
+	 * @return void
53
+	 */
54
+	public function deleting($model)
55
+	{
56
+		if ($model->getOriginal('name') == RoleEnum::ADMIN) {
57
+			\Errors::noPermissions();
58
+		}
59
+	}
60 60
 
61
-    public function deleted($model)
62
-    {
63
-        //
64
-    }
61
+	public function deleted($model)
62
+	{
63
+		//
64
+	}
65 65
 
66
-    public function restoring($model)
67
-    {
68
-        //
69
-    }
66
+	public function restoring($model)
67
+	{
68
+		//
69
+	}
70 70
 
71
-    public function restored($model)
72
-    {
73
-        //
74
-    }
71
+	public function restored($model)
72
+	{
73
+		//
74
+	}
75 75
 }
Please login to merge, or discard this patch.
src/Modules/Roles/Enums/RoleEnum.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -4,5 +4,5 @@
 block discarded – undo
4 4
 
5 5
 class RoleEnum
6 6
 {
7
-    const ADMIN = 'Admin';
7
+	const ADMIN = 'Admin';
8 8
 }
Please login to merge, or discard this patch.