Completed
Push — master ( 9ecb5e...97e3cb )
by Sherif
13:30
created
src/lang/ar/errors.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -2,25 +2,25 @@
 block discarded – undo
2 2
 
3 3
 return [
4 4
     
5
-    /**
6
-     * List of error messages used in core module.
7
-     */
8
-    'unAuthorized'           => 'من فضلك قم بتسجيل الدخول',
9
-    'invalidRefreshToken'    => 'رمز التحديث غير صالح',
10
-    'noPermissions'          => 'لا توجد صلاحية',
11
-    'loginFailed'            => 'خطأ في البريد لاكتروني او كلمة المرور',
12
-    'noSocialEmail'          => 'لا يمكن الحصول علي تابريد الاكتروني',
13
-    'userAlreadyRegistered'  => 'المستخد مسجل بالفعل.سجل الدخول بالبريد الاكتروني و كلمة السر',
14
-    'connectionError'        => 'خطأ في الاتصال',
15
-    'redisNotRunning'        => 'سيرفير الاشعارات لايعمل',
16
-    'dbQueryError'           => 'خطا في البيانات',
17
-    'cannotCreateSetting'    => 'لا يمكن اضافة اعدادات',
18
-    'cannotUpdateSettingKey' => 'لا يمكن تعديل اعدادات',
19
-    'userIsBlocked'          => 'لقد تم حظرك',
20
-    'invalidResetToken'      => 'رمز تعديل كلمة المرور خطا',
21
-    'invalidResetPassword'   => 'خطا في نعديل كلمة المرور',
22
-    'invalidOldPassword'     => 'كلمة السر القديمه خطا',
23
-    'notFound'               => 'ال :replace المطلوب غير موجود',
24
-    'generalError'           => 'حدث خطا ما',
5
+	/**
6
+	 * List of error messages used in core module.
7
+	 */
8
+	'unAuthorized'           => 'من فضلك قم بتسجيل الدخول',
9
+	'invalidRefreshToken'    => 'رمز التحديث غير صالح',
10
+	'noPermissions'          => 'لا توجد صلاحية',
11
+	'loginFailed'            => 'خطأ في البريد لاكتروني او كلمة المرور',
12
+	'noSocialEmail'          => 'لا يمكن الحصول علي تابريد الاكتروني',
13
+	'userAlreadyRegistered'  => 'المستخد مسجل بالفعل.سجل الدخول بالبريد الاكتروني و كلمة السر',
14
+	'connectionError'        => 'خطأ في الاتصال',
15
+	'redisNotRunning'        => 'سيرفير الاشعارات لايعمل',
16
+	'dbQueryError'           => 'خطا في البيانات',
17
+	'cannotCreateSetting'    => 'لا يمكن اضافة اعدادات',
18
+	'cannotUpdateSettingKey' => 'لا يمكن تعديل اعدادات',
19
+	'userIsBlocked'          => 'لقد تم حظرك',
20
+	'invalidResetToken'      => 'رمز تعديل كلمة المرور خطا',
21
+	'invalidResetPassword'   => 'خطا في نعديل كلمة المرور',
22
+	'invalidOldPassword'     => 'كلمة السر القديمه خطا',
23
+	'notFound'               => 'ال :replace المطلوب غير موجود',
24
+	'generalError'           => 'حدث خطا ما',
25 25
 
26 26
 ];
27 27
\ No newline at end of file
Please login to merge, or discard this patch.
src/Modules/V1/Acl/Http/Controllers/OauthClientsController.php 1 patch
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -8,46 +8,46 @@
 block discarded – undo
8 8
 
9 9
 class OauthClientsController extends BaseApiController
10 10
 {
11
-    /**
12
-     * The name of the model that is used by the base api controller 
13
-     * to preform actions like (add, edit ... etc).
14
-     * @var string
15
-     */
16
-    protected $model               = 'oauthClients';
11
+	/**
12
+	 * The name of the model that is used by the base api controller 
13
+	 * to preform actions like (add, edit ... etc).
14
+	 * @var string
15
+	 */
16
+	protected $model               = 'oauthClients';
17 17
 
18
-    /**
19
-     * The validations rules used by the base api controller
20
-     * to check before add.
21
-     * @var array
22
-     */
23
-    protected $validationRules  = [
24
-        'name'                   => 'required|max:255',
25
-        'redirect'               => 'required|url',
26
-        'user_id'                => 'required|array|exists:users,id'
27
-        'personal_access_client' => 'boolean',
28
-        'password_client'        => 'boolean',
29
-        'revoked'                => 'boolean'
30
-    ];
18
+	/**
19
+	 * The validations rules used by the base api controller
20
+	 * to check before add.
21
+	 * @var array
22
+	 */
23
+	protected $validationRules  = [
24
+		'name'                   => 'required|max:255',
25
+		'redirect'               => 'required|url',
26
+		'user_id'                => 'required|array|exists:users,id'
27
+		'personal_access_client' => 'boolean',
28
+		'password_client'        => 'boolean',
29
+		'revoked'                => 'boolean'
30
+	];
31 31
 
32
-    /**
33
-     * Revoke the given client.
34
-     *
35
-     * @param  integer  $clientId
36
-     * @return \Illuminate\Http\Response
37
-     */
38
-    public function revoke($clientId)
39
-    {
40
-        return \Response::json($this->repo->revoke($clientId), 200);
41
-    }
32
+	/**
33
+	 * Revoke the given client.
34
+	 *
35
+	 * @param  integer  $clientId
36
+	 * @return \Illuminate\Http\Response
37
+	 */
38
+	public function revoke($clientId)
39
+	{
40
+		return \Response::json($this->repo->revoke($clientId), 200);
41
+	}
42 42
 
43
-    /**
44
-     * Regenerate seceret for the given client.
45
-     *
46
-     * @param  integer  $clientId
47
-     * @return \Illuminate\Http\Response
48
-     */
49
-    public function regenerateSecret($clientId)
50
-    {
51
-        return \Response::json($this->repo->regenerateSecret($clientId), 200);
52
-    }
43
+	/**
44
+	 * Regenerate seceret for the given client.
45
+	 *
46
+	 * @param  integer  $clientId
47
+	 * @return \Illuminate\Http\Response
48
+	 */
49
+	public function regenerateSecret($clientId)
50
+	{
51
+		return \Response::json($this->repo->regenerateSecret($clientId), 200);
52
+	}
53 53
 }
Please login to merge, or discard this patch.
src/Modules/V1/Acl/Http/Controllers/GroupsController.php 1 patch
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -8,35 +8,35 @@
 block discarded – undo
8 8
 
9 9
 class GroupsController extends BaseApiController
10 10
 {
11
-    /**
12
-     * The name of the model that is used by the base api controller 
13
-     * to preform actions like (add, edit ... etc).
14
-     * @var string
15
-     */
16
-    protected $model               = 'groups';
11
+	/**
12
+	 * The name of the model that is used by the base api controller 
13
+	 * to preform actions like (add, edit ... etc).
14
+	 * @var string
15
+	 */
16
+	protected $model               = 'groups';
17 17
 
18
-    /**
19
-     * The validations rules used by the base api controller
20
-     * to check before add.
21
-     * @var array
22
-     */
23
-    protected $validationRules  = [
24
-    'name' => 'required|string|max:100|unique:groups,name,{id}'
25
-    ];
18
+	/**
19
+	 * The validations rules used by the base api controller
20
+	 * to check before add.
21
+	 * @var array
22
+	 */
23
+	protected $validationRules  = [
24
+	'name' => 'required|string|max:100|unique:groups,name,{id}'
25
+	];
26 26
 
27
-    /**
28
-     * Handle an assign permissions to group request.
29
-     *
30
-     * @param  \Illuminate\Http\Request  $request
31
-     * @return \Illuminate\Http\Response
32
-     */
33
-    public function assignpermissions(Request $request)
34
-    {
35
-        $this->validate($request, [
36
-            'permission_ids' => 'required|exists:permissions,id', 
37
-            'group_id'       => 'required|array|exists:groups,id'
38
-            ]);
27
+	/**
28
+	 * Handle an assign permissions to group request.
29
+	 *
30
+	 * @param  \Illuminate\Http\Request  $request
31
+	 * @return \Illuminate\Http\Response
32
+	 */
33
+	public function assignpermissions(Request $request)
34
+	{
35
+		$this->validate($request, [
36
+			'permission_ids' => 'required|exists:permissions,id', 
37
+			'group_id'       => 'required|array|exists:groups,id'
38
+			]);
39 39
 
40
-        return \Response::json($this->repo->assignPermissions($request->get('group_id'), $request->get('permission_ids')), 200);
41
-    }
40
+		return \Response::json($this->repo->assignPermissions($request->get('group_id'), $request->get('permission_ids')), 200);
41
+	}
42 42
 }
Please login to merge, or discard this patch.
src/Modules/V1/Acl/Http/Controllers/UsersController.php 1 patch
Indentation   +231 added lines, -231 removed lines patch added patch discarded remove patch
@@ -8,264 +8,264 @@
 block discarded – undo
8 8
 
9 9
 class UsersController extends BaseApiController
10 10
 {
11
-    /**
12
-     * The name of the model that is used by the base api controller 
13
-     * to preform actions like (add, edit ... etc).
14
-     * @var string
15
-     */
16
-    protected $model               = 'users';
11
+	/**
12
+	 * The name of the model that is used by the base api controller 
13
+	 * to preform actions like (add, edit ... etc).
14
+	 * @var string
15
+	 */
16
+	protected $model               = 'users';
17 17
 
18
-    /**
19
-     * List of all route actions that the base api controller
20
-     * will skip permissions check for them.
21
-     * @var array
22
-     */
23
-    protected $skipPermissionCheck = ['account', 'logout', 'changePassword'];
18
+	/**
19
+	 * List of all route actions that the base api controller
20
+	 * will skip permissions check for them.
21
+	 * @var array
22
+	 */
23
+	protected $skipPermissionCheck = ['account', 'logout', 'changePassword'];
24 24
 
25
-    /**
26
-     * List of all route actions that the base api controller
27
-     * will skip login check for them.
28
-     * @var array
29
-     */
30
-    protected $skipLoginCheck      = ['login', 'loginSocial', 'register', 'sendreset', 'resetpassword', 'refreshtoken'];
25
+	/**
26
+	 * List of all route actions that the base api controller
27
+	 * will skip login check for them.
28
+	 * @var array
29
+	 */
30
+	protected $skipLoginCheck      = ['login', 'loginSocial', 'register', 'sendreset', 'resetpassword', 'refreshtoken'];
31 31
 
32
-    /**
33
-     * The validations rules used by the base api controller
34
-     * to check before add.
35
-     * @var array
36
-     */
37
-    protected $validationRules     = [
38
-        'name'     => 'nullable|string', 
39
-        'email'    => 'required|email|unique:users,email,{id}', 
40
-        'password' => 'nullable|min:6'
41
-    ];
32
+	/**
33
+	 * The validations rules used by the base api controller
34
+	 * to check before add.
35
+	 * @var array
36
+	 */
37
+	protected $validationRules     = [
38
+		'name'     => 'nullable|string', 
39
+		'email'    => 'required|email|unique:users,email,{id}', 
40
+		'password' => 'nullable|min:6'
41
+	];
42 42
 
43
-    /**
44
-     * The loginProxy implementation.
45
-     * 
46
-     * @var array
47
-     */
48
-    protected $loginProxy;
43
+	/**
44
+	 * The loginProxy implementation.
45
+	 * 
46
+	 * @var array
47
+	 */
48
+	protected $loginProxy;
49 49
 
50
-    public function __construct(LoginProxy $loginProxy)
51
-    {        
52
-        $this->loginProxy = $loginProxy;
53
-        parent::__construct();
54
-    }
50
+	public function __construct(LoginProxy $loginProxy)
51
+	{        
52
+		$this->loginProxy = $loginProxy;
53
+		parent::__construct();
54
+	}
55 55
 
56
-    /**
57
-     * Return the logged in user account.
58
-     * 
59
-     * @return \Illuminate\Http\Response
60
-     */
61
-    public function account()
62
-    {
63
-        return \Response::json($this->repo->account($this->relations), 200);
64
-    }
56
+	/**
57
+	 * Return the logged in user account.
58
+	 * 
59
+	 * @return \Illuminate\Http\Response
60
+	 */
61
+	public function account()
62
+	{
63
+		return \Response::json($this->repo->account($this->relations), 200);
64
+	}
65 65
 
66
-    /**
67
-     * Block the user.
68
-     *
69
-     * @param  integer  $id Id of the user.
70
-     * @return \Illuminate\Http\Response
71
-     */
72
-    public function block($id)
73
-    {
74
-        return \Response::json($this->repo->block($id), 200);
75
-    }
66
+	/**
67
+	 * Block the user.
68
+	 *
69
+	 * @param  integer  $id Id of the user.
70
+	 * @return \Illuminate\Http\Response
71
+	 */
72
+	public function block($id)
73
+	{
74
+		return \Response::json($this->repo->block($id), 200);
75
+	}
76 76
 
77
-    /**
78
-     * Unblock the user.
79
-     *
80
-     * @param  integer  $id Id of the user.
81
-     * @return \Illuminate\Http\Response
82
-     */
83
-    public function unblock($id)
84
-    {
85
-        return \Response::json($this->repo->unblock($id), 200);
86
-    }
77
+	/**
78
+	 * Unblock the user.
79
+	 *
80
+	 * @param  integer  $id Id of the user.
81
+	 * @return \Illuminate\Http\Response
82
+	 */
83
+	public function unblock($id)
84
+	{
85
+		return \Response::json($this->repo->unblock($id), 200);
86
+	}
87 87
 
88
-    /**
89
-     * Logout the user.
90
-     * 
91
-     * @return \Illuminate\Http\Response
92
-     */
93
-    public function logout()
94
-    {
95
-        return \Response::json($this->loginProxy->logout(), 200);
96
-    }
88
+	/**
89
+	 * Logout the user.
90
+	 * 
91
+	 * @return \Illuminate\Http\Response
92
+	 */
93
+	public function logout()
94
+	{
95
+		return \Response::json($this->loginProxy->logout(), 200);
96
+	}
97 97
 
98
-    /**
99
-     * Handle a registration request.
100
-     *
101
-     * @param  \Illuminate\Http\Request  $request
102
-     * @return \Illuminate\Http\Response
103
-     */
104
-    public function register(Request $request)
105
-    {
106
-        $this->validate($request, [
107
-            'name'     => 'nullable|string', 
108
-            'email'    => 'required|email|unique:users,email,{id}', 
109
-            'password' => 'required|min:6'
110
-            ]);
98
+	/**
99
+	 * Handle a registration request.
100
+	 *
101
+	 * @param  \Illuminate\Http\Request  $request
102
+	 * @return \Illuminate\Http\Response
103
+	 */
104
+	public function register(Request $request)
105
+	{
106
+		$this->validate($request, [
107
+			'name'     => 'nullable|string', 
108
+			'email'    => 'required|email|unique:users,email,{id}', 
109
+			'password' => 'required|min:6'
110
+			]);
111 111
 
112
-        return \Response::json($this->repo->register($request->only('email', 'password')), 200);
113
-    }
112
+		return \Response::json($this->repo->register($request->only('email', 'password')), 200);
113
+	}
114 114
 
115
-    /**
116
-     * Handle a login request to the application.
117
-     *
118
-     * @param  \Illuminate\Http\Request  $request
119
-     * @return \Illuminate\Http\Response
120
-     */
121
-    public function login(Request $request)
122
-    {
123
-        $this->validate($request, [
124
-            'email'    => 'required|email', 
125
-            'password' => 'required|min:6',
126
-            'admin'    => 'boolean'
127
-            ]);
115
+	/**
116
+	 * Handle a login request to the application.
117
+	 *
118
+	 * @param  \Illuminate\Http\Request  $request
119
+	 * @return \Illuminate\Http\Response
120
+	 */
121
+	public function login(Request $request)
122
+	{
123
+		$this->validate($request, [
124
+			'email'    => 'required|email', 
125
+			'password' => 'required|min:6',
126
+			'admin'    => 'boolean'
127
+			]);
128 128
 
129
-        return \Response::json($this->loginProxy->login($request->only('email', 'password'), $request->get('admin')), 200);
130
-    }
129
+		return \Response::json($this->loginProxy->login($request->only('email', 'password'), $request->get('admin')), 200);
130
+	}
131 131
 
132
-    /**
133
-     * Handle a social login request of the none admin to the application.
134
-     *
135
-     * @param  \Illuminate\Http\Request  $request
136
-     * @return \Illuminate\Http\Response
137
-     */
138
-    public function loginSocial(Request $request)
139
-    {
140
-        $this->validate($request, [
141
-            'auth_code'    => 'required_without:access_token',
142
-            'access_token' => 'required_without:auth_code',
143
-            'type'         => 'required|in:facebook,google'
144
-            ]);
132
+	/**
133
+	 * Handle a social login request of the none admin to the application.
134
+	 *
135
+	 * @param  \Illuminate\Http\Request  $request
136
+	 * @return \Illuminate\Http\Response
137
+	 */
138
+	public function loginSocial(Request $request)
139
+	{
140
+		$this->validate($request, [
141
+			'auth_code'    => 'required_without:access_token',
142
+			'access_token' => 'required_without:auth_code',
143
+			'type'         => 'required|in:facebook,google'
144
+			]);
145 145
 
146
-        return \Response::json($this->repo->loginSocial($request->only('auth_code', 'access_token', 'type')), 200);
147
-    }
146
+		return \Response::json($this->repo->loginSocial($request->only('auth_code', 'access_token', 'type')), 200);
147
+	}
148 148
 
149
-    /**
150
-     * Assign the given groups to the given user.
151
-     *
152
-     * @param  \Illuminate\Http\Request  $request
153
-     * @return \Illuminate\Http\Response
154
-     */
155
-    public function assigngroups(Request $request)
156
-    {
157
-        $this->validate($request, [
158
-            'group_ids' => 'required|exists:groups,id', 
159
-            'user_id'   => 'required|exists:users,id'
160
-            ]);
149
+	/**
150
+	 * Assign the given groups to the given user.
151
+	 *
152
+	 * @param  \Illuminate\Http\Request  $request
153
+	 * @return \Illuminate\Http\Response
154
+	 */
155
+	public function assigngroups(Request $request)
156
+	{
157
+		$this->validate($request, [
158
+			'group_ids' => 'required|exists:groups,id', 
159
+			'user_id'   => 'required|exists:users,id'
160
+			]);
161 161
 
162
-        return \Response::json($this->repo->assignGroups($request->get('user_id'), $request->get('group_ids')), 200);
163
-    }
162
+		return \Response::json($this->repo->assignGroups($request->get('user_id'), $request->get('group_ids')), 200);
163
+	}
164 164
 
165
-    /**
166
-     * Send a reset link to the given user.
167
-     *
168
-     * @param  \Illuminate\Http\Request  $request
169
-     * @return \Illuminate\Http\Response
170
-     */
171
-    public function sendreset(Request $request)
172
-    {
173
-        $this->validate($request, ['email' => 'required|email']);
165
+	/**
166
+	 * Send a reset link to the given user.
167
+	 *
168
+	 * @param  \Illuminate\Http\Request  $request
169
+	 * @return \Illuminate\Http\Response
170
+	 */
171
+	public function sendreset(Request $request)
172
+	{
173
+		$this->validate($request, ['email' => 'required|email']);
174 174
 
175
-        return \Response::json($this->repo->sendReset($request->only('email')), 200);
176
-    }
175
+		return \Response::json($this->repo->sendReset($request->only('email')), 200);
176
+	}
177 177
 
178
-    /**
179
-     * Reset the given user's password.
180
-     *
181
-     * @param  \Illuminate\Http\Request  $request
182
-     * @return \Illuminate\Http\Response
183
-     */
184
-    public function resetpassword(Request $request)
185
-    {
186
-        $this->validate($request, [
187
-            'token'                 => 'required',
188
-            'email'                 => 'required|email',
189
-            'password'              => 'required|confirmed|min:6',
190
-            'password_confirmation' => 'required',
191
-        ]);
178
+	/**
179
+	 * Reset the given user's password.
180
+	 *
181
+	 * @param  \Illuminate\Http\Request  $request
182
+	 * @return \Illuminate\Http\Response
183
+	 */
184
+	public function resetpassword(Request $request)
185
+	{
186
+		$this->validate($request, [
187
+			'token'                 => 'required',
188
+			'email'                 => 'required|email',
189
+			'password'              => 'required|confirmed|min:6',
190
+			'password_confirmation' => 'required',
191
+		]);
192 192
 
193
-        return \Response::json($this->repo->resetPassword($request->only('email', 'password', 'password_confirmation', 'token')), 200);
194
-    }
193
+		return \Response::json($this->repo->resetPassword($request->only('email', 'password', 'password_confirmation', 'token')), 200);
194
+	}
195 195
 
196
-    /**
197
-     * Change the logged in user password.
198
-     *
199
-     * @param  \Illuminate\Http\Request  $request
200
-     * @return \Illuminate\Http\Response
201
-     */
202
-    public function changePassword(Request $request)
203
-    {
204
-        $this->validate($request, [
205
-            'old_password'          => 'required',
206
-            'password'              => 'required|confirmed|min:6',
207
-            'password_confirmation' => 'required',
208
-        ]);
196
+	/**
197
+	 * Change the logged in user password.
198
+	 *
199
+	 * @param  \Illuminate\Http\Request  $request
200
+	 * @return \Illuminate\Http\Response
201
+	 */
202
+	public function changePassword(Request $request)
203
+	{
204
+		$this->validate($request, [
205
+			'old_password'          => 'required',
206
+			'password'              => 'required|confirmed|min:6',
207
+			'password_confirmation' => 'required',
208
+		]);
209 209
 
210
-        return \Response::json($this->repo->changePassword($request->only('old_password', 'password', 'password_confirmation')), 200);
211
-    }
210
+		return \Response::json($this->repo->changePassword($request->only('old_password', 'password', 'password_confirmation')), 200);
211
+	}
212 212
 
213
-    /**
214
-     * Refresh the expired login token.
215
-     *
216
-     * @param  string $refreshToken
217
-     * @return \Illuminate\Http\Response
218
-     */
219
-    public function refreshtoken($refreshToken)
220
-    {
221
-        return \Response::json($this->loginProxy->refreshtoken($refreshToken), 200);
222
-    }
213
+	/**
214
+	 * Refresh the expired login token.
215
+	 *
216
+	 * @param  string $refreshToken
217
+	 * @return \Illuminate\Http\Response
218
+	 */
219
+	public function refreshtoken($refreshToken)
220
+	{
221
+		return \Response::json($this->loginProxy->refreshtoken($refreshToken), 200);
222
+	}
223 223
 
224
-    /**
225
-     * Paginate all users with inthe given group.
226
-     * 
227
-     * @param  \Illuminate\Http\Request  $request
228
-     * @param  string $groupName The name of the requested group.
229
-     * @param  integer $perPage  Number of rows per page default 15.
230
-     * @param  string  $sortBy   The name of the column to sort by.
231
-     * @param  boolean $desc     Sort ascending or descinding (1: desc, 0: asc).
232
-     * @return \Illuminate\Http\Response
233
-     */
234
-    public function group(Request $request, $groupName, $perPage = false, $sortBy = 'created_at', $desc = 1)
235
-    {
236
-        return \Response::json($this->repo->group($request->all(), $groupName, $this->relations, $perPage, $sortBy, $desc), 200);
237
-    }
224
+	/**
225
+	 * Paginate all users with inthe given group.
226
+	 * 
227
+	 * @param  \Illuminate\Http\Request  $request
228
+	 * @param  string $groupName The name of the requested group.
229
+	 * @param  integer $perPage  Number of rows per page default 15.
230
+	 * @param  string  $sortBy   The name of the column to sort by.
231
+	 * @param  boolean $desc     Sort ascending or descinding (1: desc, 0: asc).
232
+	 * @return \Illuminate\Http\Response
233
+	 */
234
+	public function group(Request $request, $groupName, $perPage = false, $sortBy = 'created_at', $desc = 1)
235
+	{
236
+		return \Response::json($this->repo->group($request->all(), $groupName, $this->relations, $perPage, $sortBy, $desc), 200);
237
+	}
238 238
 
239
-    /**
240
-     * Save the given data to the logged in user.
241
-     *
242
-     * @param  \Illuminate\Http\Request  $request
243
-     * @return \Illuminate\Http\Response
244
-     */
245
-    public function saveProfile(Request $request) 
246
-    {
247
-        foreach ($this->validationRules as &$rule) 
248
-        {
249
-            if (strpos($rule, 'exists') && ! strpos($rule, 'deleted_at,NULL')) 
250
-            {
251
-                $rule .= ',deleted_at,NULL';
252
-            }
239
+	/**
240
+	 * Save the given data to the logged in user.
241
+	 *
242
+	 * @param  \Illuminate\Http\Request  $request
243
+	 * @return \Illuminate\Http\Response
244
+	 */
245
+	public function saveProfile(Request $request) 
246
+	{
247
+		foreach ($this->validationRules as &$rule) 
248
+		{
249
+			if (strpos($rule, 'exists') && ! strpos($rule, 'deleted_at,NULL')) 
250
+			{
251
+				$rule .= ',deleted_at,NULL';
252
+			}
253 253
 
254
-            if ($request->has('id')) 
255
-            {
256
-                $rule = str_replace('{id}', $request->get('id'), $rule);
257
-            }
258
-            else
259
-            {
260
-                $rule = str_replace(',{id}', '', $rule);
261
-            }
262
-        }
254
+			if ($request->has('id')) 
255
+			{
256
+				$rule = str_replace('{id}', $request->get('id'), $rule);
257
+			}
258
+			else
259
+			{
260
+				$rule = str_replace(',{id}', '', $rule);
261
+			}
262
+		}
263 263
 
264
-        $this->validate($request, $this->validationRules);
264
+		$this->validate($request, $this->validationRules);
265 265
 
266
-        if ($this->model)
267
-        {
268
-            return \Response::json(call_user_func_array("\Core::{$this->model}", [])->saveProfile($request->all()), 200);
269
-        }
270
-    }
266
+		if ($this->model)
267
+		{
268
+			return \Response::json(call_user_func_array("\Core::{$this->model}", [])->saveProfile($request->all()), 200);
269
+		}
270
+	}
271 271
 }
Please login to merge, or discard this patch.
src/Modules/V1/Acl/Repositories/UserRepository.php 1 patch
Indentation   +357 added lines, -357 removed lines patch added patch discarded remove patch
@@ -7,368 +7,368 @@
 block discarded – undo
7 7
 
8 8
 class UserRepository extends AbstractRepository
9 9
 {
10
-    /**
11
-     * Return the model full namespace.
12
-     * 
13
-     * @return string
14
-     */
15
-    protected function getModel()
16
-    {
17
-        return 'App\Modules\V1\Acl\AclUser';
18
-    }
19
-
20
-    /**
21
-     * The loginProxy implementation.
22
-     * 
23
-     * @var array
24
-     */
25
-    protected $loginProxy;
26
-
27
-    /**
28
-     * @var The accessTokenRepository implementation.
29
-     */
30
-    private $accessTokenRepository;
31
-
32
-    public function __construct(LoginProxy $loginProxy, AccessTokenRepositoryInterface $accessTokenRepository)
33
-    {        
34
-        $this->loginProxy            = $loginProxy;
35
-        $this->accessTokenRepository = $accessTokenRepository;
36
-        parent::__construct();
37
-    }
38
-
39
-    /**
40
-     * Return the logged in user account.
41
-     *
42
-     * @param  array   $relations
43
-     * @return boolean
44
-     */
45
-    public function account($relations = [])
46
-    {
47
-        $permissions = [];
48
-        $user        = \Core::users()->find(\Auth::id(), $relations);
49
-        foreach ($user->groups()->get() as $group)
50
-        {
51
-            $group->permissions->each(function ($permission) use (&$permissions){
52
-                $permissions[$permission->model][$permission->id] = $permission->name;
53
-            });
54
-        }
55
-        $user->permissions = $permissions;
56
-
57
-       return $user;
58
-    }
59
-
60
-    /**
61
-     * Check if the logged in user or the given user 
62
-     * has the given permissions on the given model.
63
-     * 
64
-     * @param  string  $nameOfPermission
65
-     * @param  string  $model            
66
-     * @param  boolean $user
67
-     * @return boolean
68
-     */
69
-    public function can($nameOfPermission, $model, $user = false )
70
-    {      
71
-        $user        = $user = $this->find(\Auth::id(), ['groups.permissions']);
72
-        $permissions = [];
73
-
74
-        $user->groups->pluck('permissions')->each(function ($permission) use (&$permissions, $model){
75
-            $permissions = array_merge($permissions, $permission->where('model', $model)->pluck('name')->toArray()); 
76
-        });
10
+	/**
11
+	 * Return the model full namespace.
12
+	 * 
13
+	 * @return string
14
+	 */
15
+	protected function getModel()
16
+	{
17
+		return 'App\Modules\V1\Acl\AclUser';
18
+	}
19
+
20
+	/**
21
+	 * The loginProxy implementation.
22
+	 * 
23
+	 * @var array
24
+	 */
25
+	protected $loginProxy;
26
+
27
+	/**
28
+	 * @var The accessTokenRepository implementation.
29
+	 */
30
+	private $accessTokenRepository;
31
+
32
+	public function __construct(LoginProxy $loginProxy, AccessTokenRepositoryInterface $accessTokenRepository)
33
+	{        
34
+		$this->loginProxy            = $loginProxy;
35
+		$this->accessTokenRepository = $accessTokenRepository;
36
+		parent::__construct();
37
+	}
38
+
39
+	/**
40
+	 * Return the logged in user account.
41
+	 *
42
+	 * @param  array   $relations
43
+	 * @return boolean
44
+	 */
45
+	public function account($relations = [])
46
+	{
47
+		$permissions = [];
48
+		$user        = \Core::users()->find(\Auth::id(), $relations);
49
+		foreach ($user->groups()->get() as $group)
50
+		{
51
+			$group->permissions->each(function ($permission) use (&$permissions){
52
+				$permissions[$permission->model][$permission->id] = $permission->name;
53
+			});
54
+		}
55
+		$user->permissions = $permissions;
56
+
57
+	   return $user;
58
+	}
59
+
60
+	/**
61
+	 * Check if the logged in user or the given user 
62
+	 * has the given permissions on the given model.
63
+	 * 
64
+	 * @param  string  $nameOfPermission
65
+	 * @param  string  $model            
66
+	 * @param  boolean $user
67
+	 * @return boolean
68
+	 */
69
+	public function can($nameOfPermission, $model, $user = false )
70
+	{      
71
+		$user        = $user = $this->find(\Auth::id(), ['groups.permissions']);
72
+		$permissions = [];
73
+
74
+		$user->groups->pluck('permissions')->each(function ($permission) use (&$permissions, $model){
75
+			$permissions = array_merge($permissions, $permission->where('model', $model)->pluck('name')->toArray()); 
76
+		});
77 77
         
78
-        return in_array($nameOfPermission, $permissions);
79
-    }
80
-
81
-    /**
82
-     * Check if the logged in user has the given group.
83
-     * 
84
-     * @param  string  $groupName
85
-     * @param  integer $userId
86
-     * @return boolean
87
-     */
88
-    public function hasGroup($groupName, $userId = false)
89
-    {
90
-        $userId = $userId ?: \Auth::id();
91
-        $groups = $this->find($userId)->groups;
92
-        return $groups->pluck('name')->search($groupName, true) === false ? false : true;
93
-    }
94
-
95
-    /**
96
-     * Assign the given group ids to the given user.
97
-     * 
98
-     * @param  integer $user_id    
99
-     * @param  array   $group_ids
100
-     * @return object
101
-     */
102
-    public function assignGroups($user_id, $group_ids)
103
-    {
104
-        \DB::transaction(function () use ($user_id, $group_ids) {
105
-            $user = $this->find($user_id);
106
-            $user->groups()->detach();
107
-            $user->groups()->attach($group_ids);
108
-        });
109
-
110
-        return $this->find($user_id);
111
-    }
112
-
113
-    /**
114
-     * Handle a login request to the application.
115
-     * 
116
-     * @param  array   $credentials    
117
-     * @param  boolean $adminLogin
118
-     * @return object
119
-     */
120
-    public function login($credentials, $adminLogin = false)
121
-    {
122
-        if ( ! $user = $this->first(['email' => $credentials['email']])) 
123
-        {
124
-            \ErrorHandler::loginFailed();
125
-        }
126
-        else if ($adminLogin && $user->groups->pluck('name')->search('Admin', true) === false) 
127
-        {
128
-            \ErrorHandler::loginFailed();
129
-        }
130
-        else if ( ! $adminLogin && $user->groups->pluck('name')->search('Admin', true) !== false) 
131
-        {
132
-            \ErrorHandler::loginFailed();
133
-        }
134
-        else if ($user->blocked)
135
-        {
136
-            \ErrorHandler::userIsBlocked();
137
-        }
138
-
139
-        return $user;
140
-    }
141
-
142
-    /**
143
-     * Handle a social login request of the none admin to the application.
144
-     * 
145
-     * @param  array   $credentials
146
-     * @return array
147
-     */
148
-    public function loginSocial($credentials)
149
-    {
150
-        $access_token = $credentials['auth_code'] ? \Socialite::driver($credentials['type'])->getAccessToken($credentials['auth_code']) : $credentials['access_token'];
151
-        $user         = \Socialite::driver($credentials['type'])->userFromToken($access_token);
152
-
153
-        if ( ! $user->email)
154
-        {
155
-            \ErrorHandler::noSocialEmail();
156
-        }
157
-
158
-        if ( ! $registeredUser = $this->model->where('email', $user->email)->first()) 
159
-        {
160
-            $data = ['email' => $user->email, 'password' => ''];
161
-            return $this->register($data);
162
-        }
163
-        else
164
-        {
165
-            if ( ! \Auth::attempt(['email' => $registeredUser->email, 'password' => '']))
166
-            {
167
-                \ErrorHandler::userAlreadyRegistered();
168
-            }
169
-
170
-            return $this->loginProxy->login(['email' => $registeredUser->email, 'password' => ''], 0);
171
-        }
172
-    }
78
+		return in_array($nameOfPermission, $permissions);
79
+	}
80
+
81
+	/**
82
+	 * Check if the logged in user has the given group.
83
+	 * 
84
+	 * @param  string  $groupName
85
+	 * @param  integer $userId
86
+	 * @return boolean
87
+	 */
88
+	public function hasGroup($groupName, $userId = false)
89
+	{
90
+		$userId = $userId ?: \Auth::id();
91
+		$groups = $this->find($userId)->groups;
92
+		return $groups->pluck('name')->search($groupName, true) === false ? false : true;
93
+	}
94
+
95
+	/**
96
+	 * Assign the given group ids to the given user.
97
+	 * 
98
+	 * @param  integer $user_id    
99
+	 * @param  array   $group_ids
100
+	 * @return object
101
+	 */
102
+	public function assignGroups($user_id, $group_ids)
103
+	{
104
+		\DB::transaction(function () use ($user_id, $group_ids) {
105
+			$user = $this->find($user_id);
106
+			$user->groups()->detach();
107
+			$user->groups()->attach($group_ids);
108
+		});
109
+
110
+		return $this->find($user_id);
111
+	}
112
+
113
+	/**
114
+	 * Handle a login request to the application.
115
+	 * 
116
+	 * @param  array   $credentials    
117
+	 * @param  boolean $adminLogin
118
+	 * @return object
119
+	 */
120
+	public function login($credentials, $adminLogin = false)
121
+	{
122
+		if ( ! $user = $this->first(['email' => $credentials['email']])) 
123
+		{
124
+			\ErrorHandler::loginFailed();
125
+		}
126
+		else if ($adminLogin && $user->groups->pluck('name')->search('Admin', true) === false) 
127
+		{
128
+			\ErrorHandler::loginFailed();
129
+		}
130
+		else if ( ! $adminLogin && $user->groups->pluck('name')->search('Admin', true) !== false) 
131
+		{
132
+			\ErrorHandler::loginFailed();
133
+		}
134
+		else if ($user->blocked)
135
+		{
136
+			\ErrorHandler::userIsBlocked();
137
+		}
138
+
139
+		return $user;
140
+	}
141
+
142
+	/**
143
+	 * Handle a social login request of the none admin to the application.
144
+	 * 
145
+	 * @param  array   $credentials
146
+	 * @return array
147
+	 */
148
+	public function loginSocial($credentials)
149
+	{
150
+		$access_token = $credentials['auth_code'] ? \Socialite::driver($credentials['type'])->getAccessToken($credentials['auth_code']) : $credentials['access_token'];
151
+		$user         = \Socialite::driver($credentials['type'])->userFromToken($access_token);
152
+
153
+		if ( ! $user->email)
154
+		{
155
+			\ErrorHandler::noSocialEmail();
156
+		}
157
+
158
+		if ( ! $registeredUser = $this->model->where('email', $user->email)->first()) 
159
+		{
160
+			$data = ['email' => $user->email, 'password' => ''];
161
+			return $this->register($data);
162
+		}
163
+		else
164
+		{
165
+			if ( ! \Auth::attempt(['email' => $registeredUser->email, 'password' => '']))
166
+			{
167
+				\ErrorHandler::userAlreadyRegistered();
168
+			}
169
+
170
+			return $this->loginProxy->login(['email' => $registeredUser->email, 'password' => ''], 0);
171
+		}
172
+	}
173 173
     
174
-    /**
175
-     * Handle a registration request.
176
-     * 
177
-     * @param  array $credentials
178
-     * @return array
179
-     */
180
-    public function register($credentials)
181
-    {
182
-        $this->model->create($credentials)
183
-        return $this->loginProxy->login($credentials, 0);
184
-    }
185
-
186
-    /**
187
-     * Block the user.
188
-     *
189
-     * @param  integer $user_id
190
-     * @return object
191
-     */
192
-    public function block($user_id)
193
-    {
194
-        if ( ! $user = $this->find($user_id)) 
195
-        {
196
-            \ErrorHandler::notFound('user');
197
-        }
198
-        if ( ! $this->hasGroup('Admin'))
199
-        {
200
-            \ErrorHandler::noPermissions();
201
-        }
202
-        else if (\Auth::id() == $user_id)
203
-        {
204
-            \ErrorHandler::noPermissions();
205
-        }
206
-        else if ($user->groups->pluck('name')->search('Admin', true) !== false) 
207
-        {
208
-            \ErrorHandler::noPermissions();
209
-        }
210
-
211
-        $user->blocked = 1;
212
-        $user->save();
174
+	/**
175
+	 * Handle a registration request.
176
+	 * 
177
+	 * @param  array $credentials
178
+	 * @return array
179
+	 */
180
+	public function register($credentials)
181
+	{
182
+		$this->model->create($credentials)
183
+		return $this->loginProxy->login($credentials, 0);
184
+	}
185
+
186
+	/**
187
+	 * Block the user.
188
+	 *
189
+	 * @param  integer $user_id
190
+	 * @return object
191
+	 */
192
+	public function block($user_id)
193
+	{
194
+		if ( ! $user = $this->find($user_id)) 
195
+		{
196
+			\ErrorHandler::notFound('user');
197
+		}
198
+		if ( ! $this->hasGroup('Admin'))
199
+		{
200
+			\ErrorHandler::noPermissions();
201
+		}
202
+		else if (\Auth::id() == $user_id)
203
+		{
204
+			\ErrorHandler::noPermissions();
205
+		}
206
+		else if ($user->groups->pluck('name')->search('Admin', true) !== false) 
207
+		{
208
+			\ErrorHandler::noPermissions();
209
+		}
210
+
211
+		$user->blocked = 1;
212
+		$user->save();
213 213
         
214
-        return $user;
215
-    }
216
-
217
-    /**
218
-     * Unblock the user.
219
-     *
220
-     * @param  integer $user_id
221
-     * @return object
222
-     */
223
-    public function unblock($user_id)
224
-    {
225
-        if ( ! $this->hasGroup('Admin'))
226
-        {
227
-            \ErrorHandler::noPermissions();
228
-        }
229
-
230
-        $user          = $this->find($user_id);
231
-        $user->blocked = 0;
232
-        $user->save();
233
-
234
-        return $user;
235
-    }
236
-
237
-    /**
238
-     * Send a reset link to the given user.
239
-     *
240
-     * @param  string  $email
241
-     * @return void
242
-     */
243
-    public function sendReset($email)
244
-    {
245
-        if ( ! $user = $this->model->where('email', $email)->first())
246
-        {
247
-            \ErrorHandler::notFound('email');
248
-        }
249
-
250
-        $url   = $this->config['resetLink'];
251
-        $token = \Password::getRepository()->create($user);
214
+		return $user;
215
+	}
216
+
217
+	/**
218
+	 * Unblock the user.
219
+	 *
220
+	 * @param  integer $user_id
221
+	 * @return object
222
+	 */
223
+	public function unblock($user_id)
224
+	{
225
+		if ( ! $this->hasGroup('Admin'))
226
+		{
227
+			\ErrorHandler::noPermissions();
228
+		}
229
+
230
+		$user          = $this->find($user_id);
231
+		$user->blocked = 0;
232
+		$user->save();
233
+
234
+		return $user;
235
+	}
236
+
237
+	/**
238
+	 * Send a reset link to the given user.
239
+	 *
240
+	 * @param  string  $email
241
+	 * @return void
242
+	 */
243
+	public function sendReset($email)
244
+	{
245
+		if ( ! $user = $this->model->where('email', $email)->first())
246
+		{
247
+			\ErrorHandler::notFound('email');
248
+		}
249
+
250
+		$url   = $this->config['resetLink'];
251
+		$token = \Password::getRepository()->create($user);
252 252
         
253
-        \Mail::send('acl::resetpassword', ['user' => $user, 'url' => $url, 'token' => $token], function ($m) use ($user) {
254
-            $m->to($user->email, $user->name)->subject('Your Password Reset Link');
255
-        });
256
-    }
257
-
258
-    /**
259
-     * Reset the given user's password.
260
-     *
261
-     * @param  array  $credentials
262
-     * @return array
263
-     */
264
-    public function resetPassword($credentials)
265
-    {
266
-        $response = \Password::reset($credentials, function ($user, $password) {
267
-            $user->password = $password;
268
-            $user->save();
269
-        });
270
-
271
-        switch ($response) {
272
-            case \Password::PASSWORD_RESET:
273
-                return 'success';
253
+		\Mail::send('acl::resetpassword', ['user' => $user, 'url' => $url, 'token' => $token], function ($m) use ($user) {
254
+			$m->to($user->email, $user->name)->subject('Your Password Reset Link');
255
+		});
256
+	}
257
+
258
+	/**
259
+	 * Reset the given user's password.
260
+	 *
261
+	 * @param  array  $credentials
262
+	 * @return array
263
+	 */
264
+	public function resetPassword($credentials)
265
+	{
266
+		$response = \Password::reset($credentials, function ($user, $password) {
267
+			$user->password = $password;
268
+			$user->save();
269
+		});
270
+
271
+		switch ($response) {
272
+			case \Password::PASSWORD_RESET:
273
+				return 'success';
274 274
                 
275
-            case \Password::INVALID_TOKEN:
276
-                \ErrorHandler::invalidResetToken('token');
277
-
278
-            case \Password::INVALID_PASSWORD:
279
-                \ErrorHandler::invalidResetPassword('email');
280
-
281
-            case \Password::INVALID_USER:
282
-                \ErrorHandler::notFound('user');
283
-
284
-            default:
285
-                \ErrorHandler::generalError();
286
-        }
287
-    }
288
-
289
-    /**
290
-     * Change the logged in user password.
291
-     *
292
-     * @param  array  $credentials
293
-     * @return void
294
-     */
295
-    public function changePassword($credentials)
296
-    {
297
-        $user = \Auth::user();
298
-        if ( ! \Hash::check($credentials['old_password'], $user->password)) 
299
-        {
300
-            \ErrorHandler::invalidOldPassword();
301
-        }
302
-
303
-        $user->password = $credentials['password'];
304
-        $user->save();
305
-    }
306
-
307
-    /**
308
-     * Paginate all users in the given group based on the given conditions.
309
-     * 
310
-     * @param  string  $groupName
311
-     * @param  array   $relations
312
-     * @param  integer $perPage
313
-     * @param  string  $sortBy
314
-     * @param  boolean $desc
315
-     * @return \Illuminate\Http\Response
316
-     */
317
-    public function group($conditions, $groupName, $relations, $perPage, $sortBy, $desc)
318
-    {   
319
-        unset($conditions['page']);
320
-        $conditions = $this->constructConditions($conditions, $this->model);
321
-        $sort       = $desc ? 'desc' : 'asc';
322
-        $model      = call_user_func_array("{$this->getModel()}::with", array($relations));
323
-
324
-        $model->whereHas('groups', function($q) use ($groupName){
325
-            $q->where('name', $groupName);
326
-        });
275
+			case \Password::INVALID_TOKEN:
276
+				\ErrorHandler::invalidResetToken('token');
277
+
278
+			case \Password::INVALID_PASSWORD:
279
+				\ErrorHandler::invalidResetPassword('email');
280
+
281
+			case \Password::INVALID_USER:
282
+				\ErrorHandler::notFound('user');
283
+
284
+			default:
285
+				\ErrorHandler::generalError();
286
+		}
287
+	}
288
+
289
+	/**
290
+	 * Change the logged in user password.
291
+	 *
292
+	 * @param  array  $credentials
293
+	 * @return void
294
+	 */
295
+	public function changePassword($credentials)
296
+	{
297
+		$user = \Auth::user();
298
+		if ( ! \Hash::check($credentials['old_password'], $user->password)) 
299
+		{
300
+			\ErrorHandler::invalidOldPassword();
301
+		}
302
+
303
+		$user->password = $credentials['password'];
304
+		$user->save();
305
+	}
306
+
307
+	/**
308
+	 * Paginate all users in the given group based on the given conditions.
309
+	 * 
310
+	 * @param  string  $groupName
311
+	 * @param  array   $relations
312
+	 * @param  integer $perPage
313
+	 * @param  string  $sortBy
314
+	 * @param  boolean $desc
315
+	 * @return \Illuminate\Http\Response
316
+	 */
317
+	public function group($conditions, $groupName, $relations, $perPage, $sortBy, $desc)
318
+	{   
319
+		unset($conditions['page']);
320
+		$conditions = $this->constructConditions($conditions, $this->model);
321
+		$sort       = $desc ? 'desc' : 'asc';
322
+		$model      = call_user_func_array("{$this->getModel()}::with", array($relations));
323
+
324
+		$model->whereHas('groups', function($q) use ($groupName){
325
+			$q->where('name', $groupName);
326
+		});
327 327
 
328 328
         
329
-        if (count($conditions['conditionValues']))
330
-        {
331
-            $model->whereRaw($conditions['conditionString'], $conditions['conditionValues']);
332
-        }
333
-
334
-        if ($perPage) 
335
-        {
336
-            return $model->orderBy($sortBy, $sort)->paginate($perPage);
337
-        }
338
-
339
-        return $model->orderBy($sortBy, $sort)->get();
340
-    }
341
-
342
-    /**
343
-     * Save the given data to the logged in user.
344
-     *
345
-     * @param  array $credentials
346
-     * @return object
347
-     */
348
-    public function saveProfile($credentials) 
349
-    {
350
-        $user = \Auth::user();
351
-        $user->save($credentials);
352
-
353
-        return $user;
354
-    }
355
-
356
-    /**
357
-     * Ensure access token hasn't expired or revoked.
358
-     * 
359
-     * @param  string $accessToken
360
-     * @return boolean
361
-     */
362
-    public function accessTokenExpiredOrRevoked($accessToken)
363
-    {
364
-        $data = new ValidationData();
365
-        $data->setCurrentTime(time());
366
-
367
-        if ($accessToken->validate($data) === false || $this->accessTokenRepository->isAccessTokenRevoked($accessToken->getClaim('jti'))) 
368
-        {
369
-            return true;
370
-        }
371
-
372
-        return false;
373
-    }
329
+		if (count($conditions['conditionValues']))
330
+		{
331
+			$model->whereRaw($conditions['conditionString'], $conditions['conditionValues']);
332
+		}
333
+
334
+		if ($perPage) 
335
+		{
336
+			return $model->orderBy($sortBy, $sort)->paginate($perPage);
337
+		}
338
+
339
+		return $model->orderBy($sortBy, $sort)->get();
340
+	}
341
+
342
+	/**
343
+	 * Save the given data to the logged in user.
344
+	 *
345
+	 * @param  array $credentials
346
+	 * @return object
347
+	 */
348
+	public function saveProfile($credentials) 
349
+	{
350
+		$user = \Auth::user();
351
+		$user->save($credentials);
352
+
353
+		return $user;
354
+	}
355
+
356
+	/**
357
+	 * Ensure access token hasn't expired or revoked.
358
+	 * 
359
+	 * @param  string $accessToken
360
+	 * @return boolean
361
+	 */
362
+	public function accessTokenExpiredOrRevoked($accessToken)
363
+	{
364
+		$data = new ValidationData();
365
+		$data->setCurrentTime(time());
366
+
367
+		if ($accessToken->validate($data) === false || $this->accessTokenRepository->isAccessTokenRevoked($accessToken->getClaim('jti'))) 
368
+		{
369
+			return true;
370
+		}
371
+
372
+		return false;
373
+	}
374 374
 }
Please login to merge, or discard this patch.
src/Modules/V1/Acl/Repositories/OauthClientRepository.php 1 patch
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -14,27 +14,27 @@
 block discarded – undo
14 14
 		return 'App\Modules\V1\Acl\OauthClient';
15 15
 	}
16 16
 
17
-    /**
18
-     * Revoke the given client.
19
-     *
20
-     * @param  integer  $clientId
21
-     * @return void
22
-     */
23
-    public function revoke($clientId)
24
-    {
25
-    	$client = $this->find($clientId);
26
-        $client->tokens()->update(['revoked' => true]);
27
-        $client->forceFill(['revoked' => true])->save();
28
-    }
17
+	/**
18
+	 * Revoke the given client.
19
+	 *
20
+	 * @param  integer  $clientId
21
+	 * @return void
22
+	 */
23
+	public function revoke($clientId)
24
+	{
25
+		$client = $this->find($clientId);
26
+		$client->tokens()->update(['revoked' => true]);
27
+		$client->forceFill(['revoked' => true])->save();
28
+	}
29 29
 
30
-    /**
31
-     * Revoke the given client.
32
-     *
33
-     * @param  integer  $clientId
34
-     * @return void
35
-     */
36
-    public function revoke($clientId)
37
-    {
30
+	/**
31
+	 * Revoke the given client.
32
+	 *
33
+	 * @param  integer  $clientId
34
+	 * @return void
35
+	 */
36
+	public function revoke($clientId)
37
+	{
38 38
 		$this->update($clientId, ['secret' => str_random(40)]);
39
-    }
39
+	}
40 40
 }
Please login to merge, or discard this patch.
src/Modules/V1/Acl/OauthClient.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -6,23 +6,23 @@
 block discarded – undo
6 6
 
7 7
 class OauthClient extends Client
8 8
 {
9
-    protected $dates    = ['created_at', 'updated_at'];
10
-    protected $fillable = ['name', 'redirect', 'user_id', 'personal_access_client', 'password_client', 'revoked'];
11
-    public $searchable  = ['name'];
9
+	protected $dates    = ['created_at', 'updated_at'];
10
+	protected $fillable = ['name', 'redirect', 'user_id', 'personal_access_client', 'password_client', 'revoked'];
11
+	public $searchable  = ['name'];
12 12
     
13
-    public function getCreatedAtAttribute($value)
14
-    {
15
-        return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
16
-    }
13
+	public function getCreatedAtAttribute($value)
14
+	{
15
+		return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
16
+	}
17 17
 
18
-    public function getUpdatedAtAttribute($value)
19
-    {
20
-        return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
21
-    }
18
+	public function getUpdatedAtAttribute($value)
19
+	{
20
+		return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
21
+	}
22 22
     
23
-    public static function boot()
24
-    {
25
-        parent::boot();
26
-        parent::observe(\App::make('App\Modules\V1\Acl\ModelObservers\OauthClientObserver'));
27
-    }
23
+	public static function boot()
24
+	{
25
+		parent::boot();
26
+		parent::observe(\App::make('App\Modules\V1\Acl\ModelObservers\OauthClientObserver'));
27
+	}
28 28
 }
Please login to merge, or discard this patch.
src/Modules/V1/Acl/AclUser.php 1 patch
Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -7,89 +7,89 @@
 block discarded – undo
7 7
 
8 8
 class AclUser extends User {
9 9
 
10
-    use SoftDeletes, HasApiTokens;
11
-    protected $table    = 'users';
12
-    protected $dates    = ['created_at', 'updated_at', 'deleted_at'];
13
-    protected $hidden   = ['password', 'remember_token','deleted_at'];
14
-    protected $guarded  = ['id'];
15
-    protected $fillable = ['name', 'email', 'password'];
16
-    public $searchable  = ['name', 'email'];
10
+	use SoftDeletes, HasApiTokens;
11
+	protected $table    = 'users';
12
+	protected $dates    = ['created_at', 'updated_at', 'deleted_at'];
13
+	protected $hidden   = ['password', 'remember_token','deleted_at'];
14
+	protected $guarded  = ['id'];
15
+	protected $fillable = ['name', 'email', 'password'];
16
+	public $searchable  = ['name', 'email'];
17 17
     
18
-    public function getCreatedAtAttribute($value)
19
-    {
20
-        return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
21
-    }
18
+	public function getCreatedAtAttribute($value)
19
+	{
20
+		return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
21
+	}
22 22
 
23
-    public function getUpdatedAtAttribute($value)
24
-    {
25
-        return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
26
-    }
23
+	public function getUpdatedAtAttribute($value)
24
+	{
25
+		return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
26
+	}
27 27
 
28
-    public function getDeletedAtAttribute($value)
29
-    {
30
-        return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
31
-    }
28
+	public function getDeletedAtAttribute($value)
29
+	{
30
+		return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
31
+	}
32 32
 
33
-    /**
34
-     * Encrypt the password attribute before
35
-     * saving it in the storage.
36
-     * 
37
-     * @param string $value 
38
-     */
39
-    public function setPasswordAttribute($value)
40
-    {
41
-        $this->attributes['password'] = bcrypt($value);
42
-    }
33
+	/**
34
+	 * Encrypt the password attribute before
35
+	 * saving it in the storage.
36
+	 * 
37
+	 * @param string $value 
38
+	 */
39
+	public function setPasswordAttribute($value)
40
+	{
41
+		$this->attributes['password'] = bcrypt($value);
42
+	}
43 43
 
44
-    public function groups()
45
-    {
46
-        return $this->belongsToMany('\App\Modules\V1\Acl\AclGroup','users_groups','user_id','group_id')->whereNull('users_groups.deleted_at')->withTimestamps();
47
-    }
44
+	public function groups()
45
+	{
46
+		return $this->belongsToMany('\App\Modules\V1\Acl\AclGroup','users_groups','user_id','group_id')->whereNull('users_groups.deleted_at')->withTimestamps();
47
+	}
48 48
 
49
-    /**
50
-     * Return fcm device tokens related to the user.
51
-     * @return array
52
-     */
53
-    public function routeNotificationForFCM()
54
-    {
55
-        $devices = \Core::pushNotificationsDevices()->findBy(['user_id' => $this->id]);
56
-        $tokens  = [];
49
+	/**
50
+	 * Return fcm device tokens related to the user.
51
+	 * @return array
52
+	 */
53
+	public function routeNotificationForFCM()
54
+	{
55
+		$devices = \Core::pushNotificationsDevices()->findBy(['user_id' => $this->id]);
56
+		$tokens  = [];
57 57
 
58
-        foreach ($devices as $device) 
59
-        {
60
-            $accessToken = decrypt($device->access_token);
58
+		foreach ($devices as $device) 
59
+		{
60
+			$accessToken = decrypt($device->access_token);
61 61
 
62
-            try
63
-            {
64
-                if (\Core::users()->accessTokenExpiredOrRevoked($accessToken)) 
65
-                {
66
-                    continue;
67
-                }
62
+			try
63
+			{
64
+				if (\Core::users()->accessTokenExpiredOrRevoked($accessToken)) 
65
+				{
66
+					continue;
67
+				}
68 68
 
69
-                $tokens[] = $device->device_token;
70
-            } 
71
-            catch (\Exception $e) 
72
-            {
73
-                $device->forceDelete();
74
-            }
75
-        }
69
+				$tokens[] = $device->device_token;
70
+			} 
71
+			catch (\Exception $e) 
72
+			{
73
+				$device->forceDelete();
74
+			}
75
+		}
76 76
 
77
-        return $tokens;
78
-    }
77
+		return $tokens;
78
+	}
79 79
 
80
-    /**
81
-     * The channels the user receives notification broadcasts on.
82
-     *
83
-     * @return string
84
-     */
85
-    public function receivesBroadcastNotificationsOn()
86
-    {
87
-        return 'users.' . $this->id;
88
-    }
80
+	/**
81
+	 * The channels the user receives notification broadcasts on.
82
+	 *
83
+	 * @return string
84
+	 */
85
+	public function receivesBroadcastNotificationsOn()
86
+	{
87
+		return 'users.' . $this->id;
88
+	}
89 89
     
90
-    public static function boot()
91
-    {
92
-        parent::boot();
93
-        parent::observe(\App::make('App\Modules\V1\Acl\ModelObservers\AclUserObserver'));
94
-    }
90
+	public static function boot()
91
+	{
92
+		parent::boot();
93
+		parent::observe(\App::make('App\Modules\V1\Acl\ModelObservers\AclUserObserver'));
94
+	}
95 95
 }
Please login to merge, or discard this patch.
src/Modules/V1/Acl/ModelObservers/AclUserObserver.php 1 patch
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -5,66 +5,66 @@
 block discarded – undo
5 5
  */
6 6
 class AclUserObserver {
7 7
 
8
-    public function saving($model)
9
-    {
10
-        //
11
-    }
8
+	public function saving($model)
9
+	{
10
+		//
11
+	}
12 12
 
13
-    public function saved($model)
14
-    {
15
-        //
16
-    }
13
+	public function saved($model)
14
+	{
15
+		//
16
+	}
17 17
 
18
-    public function creating($model)
19
-    {
20
-        //
21
-    }
18
+	public function creating($model)
19
+	{
20
+		//
21
+	}
22 22
 
23
-    public function created($model)
24
-    {
25
-        //
26
-    }
23
+	public function created($model)
24
+	{
25
+		//
26
+	}
27 27
 
28
-    public function updating($model)
29
-    {
30
-        if ($model->password) 
31
-        {
32
-            $model->last_change_password = \Carbon\Carbon::now()->toDateTimeString();
33
-        }
34
-    }
28
+	public function updating($model)
29
+	{
30
+		if ($model->password) 
31
+		{
32
+			$model->last_change_password = \Carbon\Carbon::now()->toDateTimeString();
33
+		}
34
+	}
35 35
 
36
-    public function updated($model)
37
-    {
38
-        //
39
-    }
36
+	public function updated($model)
37
+	{
38
+		//
39
+	}
40 40
 
41
-    /**
42
-     * Soft delete user logs.
43
-     * 
44
-     * @param  object $model the delted model.
45
-     * @return void
46
-     */
47
-    public function deleting($model)
48
-    {
49
-        if ($model->getOriginal('id') == \Auth::id()) 
50
-        {
51
-            \ErrorHandler::noPermissions();
52
-        }
53
-        $model->logs()->delete();
54
-    }
41
+	/**
42
+	 * Soft delete user logs.
43
+	 * 
44
+	 * @param  object $model the delted model.
45
+	 * @return void
46
+	 */
47
+	public function deleting($model)
48
+	{
49
+		if ($model->getOriginal('id') == \Auth::id()) 
50
+		{
51
+			\ErrorHandler::noPermissions();
52
+		}
53
+		$model->logs()->delete();
54
+	}
55 55
 
56
-    public function deleted($model)
57
-    {
58
-        //
59
-    }
56
+	public function deleted($model)
57
+	{
58
+		//
59
+	}
60 60
 
61
-    public function restoring($model)
62
-    {
63
-        $model->logs()->restore();
64
-    }
61
+	public function restoring($model)
62
+	{
63
+		$model->logs()->restore();
64
+	}
65 65
 
66
-    public function restored($model)
67
-    {
68
-        //
69
-    }
66
+	public function restored($model)
67
+	{
68
+		//
69
+	}
70 70
 }
71 71
\ No newline at end of file
Please login to merge, or discard this patch.