Completed
Push — master ( cf2713...aee5ae )
by Sherif
02:07
created
src/Modules/Users/ModelObservers/AclUserObserver.php 1 patch
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -6,62 +6,62 @@
 block discarded – undo
6 6
 class AclUserObserver
7 7
 {
8 8
 
9
-    public function saving($model)
10
-    {
11
-        if ($model->isDirty('profile_picture')) {
12
-            \Media::deleteImage($model->getOriginal('profile_picture'));
13
-        }
14
-    }
9
+	public function saving($model)
10
+	{
11
+		if ($model->isDirty('profile_picture')) {
12
+			\Media::deleteImage($model->getOriginal('profile_picture'));
13
+		}
14
+	}
15 15
 
16
-    public function saved($model)
17
-    {
18
-        //
19
-    }
16
+	public function saved($model)
17
+	{
18
+		//
19
+	}
20 20
 
21
-    public function creating($model)
22
-    {
23
-        //
24
-    }
21
+	public function creating($model)
22
+	{
23
+		//
24
+	}
25 25
 
26
-    public function created($model)
27
-    {
28
-        //
29
-    }
26
+	public function created($model)
27
+	{
28
+		//
29
+	}
30 30
 
31
-    public function updating($model)
32
-    {
33
-        //
34
-    }
31
+	public function updating($model)
32
+	{
33
+		//
34
+	}
35 35
 
36
-    public function updated($model)
37
-    {
38
-        if ($model->isDirty('blocked') && $model->blocked) {
39
-            $model->tokens()->each(function ($token) {
36
+	public function updated($model)
37
+	{
38
+		if ($model->isDirty('blocked') && $model->blocked) {
39
+			$model->tokens()->each(function ($token) {
40 40
 
41
-                \Core::oauthClients()->revokeAccessToken($token);
42
-            });
43
-        }
44
-    }
41
+				\Core::oauthClients()->revokeAccessToken($token);
42
+			});
43
+		}
44
+	}
45 45
 
46
-    public function deleting($model)
47
-    {
48
-        if ($model->getOriginal('id') == \Auth::id()) {
49
-            \ErrorHandler::noPermissions();
50
-        }
51
-    }
46
+	public function deleting($model)
47
+	{
48
+		if ($model->getOriginal('id') == \Auth::id()) {
49
+			\ErrorHandler::noPermissions();
50
+		}
51
+	}
52 52
 
53
-    public function deleted($model)
54
-    {
55
-        //
56
-    }
53
+	public function deleted($model)
54
+	{
55
+		//
56
+	}
57 57
 
58
-    public function restoring($model)
59
-    {
60
-        //
61
-    }
58
+	public function restoring($model)
59
+	{
60
+		//
61
+	}
62 62
 
63
-    public function restored($model)
64
-    {
65
-        //
66
-    }
63
+	public function restored($model)
64
+	{
65
+		//
66
+	}
67 67
 }
Please login to merge, or discard this patch.
src/Modules/Users/Routes/api.php 1 patch
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -15,30 +15,30 @@
 block discarded – undo
15 15
 
16 16
 Route::group(['prefix' => 'users'], function () {
17 17
 
18
-    Route::get('/', 'UserController@index');
19
-    Route::get('/{id}', 'UserController@find');
20
-    Route::post('/', 'UserController@insert');
21
-    Route::put('/', 'UserController@update');
22
-    Route::delete('/{id}', 'UserController@delete');
23
-    Route::get('list/deleted', 'UserController@deleted');
24
-    Route::patch('restore/{id}', 'UserController@restore');
25
-    Route::get('block/{id}', 'UserController@block');
26
-    Route::get('unblock/{id}', 'UserController@unblock');
27
-    Route::post('assign/roles', 'UserController@assignRoles');
18
+	Route::get('/', 'UserController@index');
19
+	Route::get('/{id}', 'UserController@find');
20
+	Route::post('/', 'UserController@insert');
21
+	Route::put('/', 'UserController@update');
22
+	Route::delete('/{id}', 'UserController@delete');
23
+	Route::get('list/deleted', 'UserController@deleted');
24
+	Route::patch('restore/{id}', 'UserController@restore');
25
+	Route::get('block/{id}', 'UserController@block');
26
+	Route::get('unblock/{id}', 'UserController@unblock');
27
+	Route::post('assign/roles', 'UserController@assignRoles');
28 28
 
29
-    Route::group(['prefix' => 'account'], function () {
29
+	Route::group(['prefix' => 'account'], function () {
30 30
 
31
-        Route::get('my', 'UserController@account');
32
-        Route::get('logout', 'UserController@logout');
33
-        Route::post('refresh/token', 'UserController@refreshToken');
34
-        Route::post('save', 'UserController@saveProfile');
35
-        Route::post('register', 'UserController@register');
36
-        Route::post('login', 'UserController@login');
37
-        Route::post('login/social', 'UserController@loginSocial');
38
-        Route::post('send/reset', 'UserController@sendReset');
39
-        Route::post('reset/password', 'UserController@resetPassword');
40
-        Route::post('change/password', 'UserController@changePassword');
41
-        Route::post('confirm/email', 'UserController@confirmEmail');
42
-        Route::post('resend/email/confirmation', 'UserController@resendEmailConfirmation');
43
-    });
31
+		Route::get('my', 'UserController@account');
32
+		Route::get('logout', 'UserController@logout');
33
+		Route::post('refresh/token', 'UserController@refreshToken');
34
+		Route::post('save', 'UserController@saveProfile');
35
+		Route::post('register', 'UserController@register');
36
+		Route::post('login', 'UserController@login');
37
+		Route::post('login/social', 'UserController@loginSocial');
38
+		Route::post('send/reset', 'UserController@sendReset');
39
+		Route::post('reset/password', 'UserController@resetPassword');
40
+		Route::post('change/password', 'UserController@changePassword');
41
+		Route::post('confirm/email', 'UserController@confirmEmail');
42
+		Route::post('resend/email/confirmation', 'UserController@resendEmailConfirmation');
43
+	});
44 44
 });
Please login to merge, or discard this patch.
src/Modules/Users/Database/Seeds/UsersTableSeeder.php 1 patch
Indentation   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -8,105 +8,105 @@
 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
-         * Create Default roles.
20
-         */
21
-        $role = Role::updateOrInsert([
22
-            'name' => 'Admin',
23
-        ],[
24
-            'created_at' => \DB::raw('NOW()'),
25
-            'updated_at' => \DB::raw('NOW()')
26
-        ]);
11
+	/**
12
+	 * Run the database seeds.
13
+	 *
14
+	 * @return void
15
+	 */
16
+	public function run()
17
+	{
18
+		/**
19
+		 * Create Default roles.
20
+		 */
21
+		$role = Role::updateOrInsert([
22
+			'name' => 'Admin',
23
+		],[
24
+			'created_at' => \DB::raw('NOW()'),
25
+			'updated_at' => \DB::raw('NOW()')
26
+		]);
27 27
 
28
-        /**
29
-         * Create Default user.
30
-         */
31
-        AclUser::updateOrInsert([
32
-            'email' => '[email protected]',
33
-        ],[
34
-            'name'       => 'Admin',
35
-            'password'   => \Hash::make('123456'),
36
-            'confirmed'  => 1,
37
-            'created_at' => \DB::raw('NOW()'),
38
-            'updated_at' => \DB::raw('NOW()')
39
-        ]);
28
+		/**
29
+		 * Create Default user.
30
+		 */
31
+		AclUser::updateOrInsert([
32
+			'email' => '[email protected]',
33
+		],[
34
+			'name'       => 'Admin',
35
+			'password'   => \Hash::make('123456'),
36
+			'confirmed'  => 1,
37
+			'created_at' => \DB::raw('NOW()'),
38
+			'updated_at' => \DB::raw('NOW()')
39
+		]);
40 40
 
41
-        /**
42
-         * Insert the permissions related to users table.
43
-         */
44
-        \DB::table('permissions')->insert(
45
-            [
46
-                /**
47
-                 * Users model permissions.
48
-                 */
49
-                [
50
-                'name'       => 'index',
51
-                'model'      => 'user',
52
-                'created_at' => \DB::raw('NOW()'),
53
-                'updated_at' => \DB::raw('NOW()')
54
-                ],
55
-                [
56
-                'name'       => 'find',
57
-                'model'      => 'user',
58
-                'created_at' => \DB::raw('NOW()'),
59
-                'updated_at' => \DB::raw('NOW()')
60
-                ],
61
-                [
62
-                'name'       => 'insert',
63
-                'model'      => 'user',
64
-                'created_at' => \DB::raw('NOW()'),
65
-                'updated_at' => \DB::raw('NOW()')
66
-                ],
67
-                [
68
-                'name'       => 'update',
69
-                'model'      => 'user',
70
-                'created_at' => \DB::raw('NOW()'),
71
-                'updated_at' => \DB::raw('NOW()')
72
-                ],
73
-                [
74
-                'name'       => 'delete',
75
-                'model'      => 'user',
76
-                'created_at' => \DB::raw('NOW()'),
77
-                'updated_at' => \DB::raw('NOW()')
78
-                ],
79
-                [
80
-                'name'       => 'deleted',
81
-                'model'      => 'user',
82
-                'created_at' => \DB::raw('NOW()'),
83
-                'updated_at' => \DB::raw('NOW()')
84
-                ],
85
-                [
86
-                'name'       => 'restore',
87
-                'model'      => 'user',
88
-                'created_at' => \DB::raw('NOW()'),
89
-                'updated_at' => \DB::raw('NOW()')
90
-                ],
91
-                [
92
-                'name'       => 'assignRoles',
93
-                'model'      => 'user',
94
-                'created_at' => \DB::raw('NOW()'),
95
-                'updated_at' => \DB::raw('NOW()')
96
-                ],
97
-                [
98
-                'name'       => 'block',
99
-                'model'      => 'user',
100
-                'created_at' => \DB::raw('NOW()'),
101
-                'updated_at' => \DB::raw('NOW()')
102
-                ],
103
-                [
104
-                'name'       => 'unblock',
105
-                'model'      => 'user',
106
-                'created_at' => \DB::raw('NOW()'),
107
-                'updated_at' => \DB::raw('NOW()')
108
-                ]
109
-            ]
110
-        );
111
-    }
41
+		/**
42
+		 * Insert the permissions related to users table.
43
+		 */
44
+		\DB::table('permissions')->insert(
45
+			[
46
+				/**
47
+				 * Users model permissions.
48
+				 */
49
+				[
50
+				'name'       => 'index',
51
+				'model'      => 'user',
52
+				'created_at' => \DB::raw('NOW()'),
53
+				'updated_at' => \DB::raw('NOW()')
54
+				],
55
+				[
56
+				'name'       => 'find',
57
+				'model'      => 'user',
58
+				'created_at' => \DB::raw('NOW()'),
59
+				'updated_at' => \DB::raw('NOW()')
60
+				],
61
+				[
62
+				'name'       => 'insert',
63
+				'model'      => 'user',
64
+				'created_at' => \DB::raw('NOW()'),
65
+				'updated_at' => \DB::raw('NOW()')
66
+				],
67
+				[
68
+				'name'       => 'update',
69
+				'model'      => 'user',
70
+				'created_at' => \DB::raw('NOW()'),
71
+				'updated_at' => \DB::raw('NOW()')
72
+				],
73
+				[
74
+				'name'       => 'delete',
75
+				'model'      => 'user',
76
+				'created_at' => \DB::raw('NOW()'),
77
+				'updated_at' => \DB::raw('NOW()')
78
+				],
79
+				[
80
+				'name'       => 'deleted',
81
+				'model'      => 'user',
82
+				'created_at' => \DB::raw('NOW()'),
83
+				'updated_at' => \DB::raw('NOW()')
84
+				],
85
+				[
86
+				'name'       => 'restore',
87
+				'model'      => 'user',
88
+				'created_at' => \DB::raw('NOW()'),
89
+				'updated_at' => \DB::raw('NOW()')
90
+				],
91
+				[
92
+				'name'       => 'assignRoles',
93
+				'model'      => 'user',
94
+				'created_at' => \DB::raw('NOW()'),
95
+				'updated_at' => \DB::raw('NOW()')
96
+				],
97
+				[
98
+				'name'       => 'block',
99
+				'model'      => 'user',
100
+				'created_at' => \DB::raw('NOW()'),
101
+				'updated_at' => \DB::raw('NOW()')
102
+				],
103
+				[
104
+				'name'       => 'unblock',
105
+				'model'      => 'user',
106
+				'created_at' => \DB::raw('NOW()'),
107
+				'updated_at' => \DB::raw('NOW()')
108
+				]
109
+			]
110
+		);
111
+	}
112 112
 }
Please login to merge, or discard this patch.
src/Modules/Users/Database/Seeds/AssignRelationsSeeder.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -6,27 +6,27 @@
 block discarded – undo
6 6
 
7 7
 class AssignRelationsSeeder extends Seeder
8 8
 {
9
-    /**
10
-     * Run the database seeds.
11
-     *
12
-     * @return void
13
-     */
14
-    public function run()
15
-    {
16
-        $adminRoleId = \DB::table('roles')->where('name', 'admin')->select('id')->first()->id;
9
+	/**
10
+	 * Run the database seeds.
11
+	 *
12
+	 * @return void
13
+	 */
14
+	public function run()
15
+	{
16
+		$adminRoleId = \DB::table('roles')->where('name', 'admin')->select('id')->first()->id;
17 17
 
18
-        /**
19
-         * Assign the permissions to the admin role.
20
-         */
21
-        \DB::table('permissions')->orderBy('created_at', 'asc')->whereIn('model', ['user'])->each(function ($permission) use ($adminRoleId) {
22
-            \DB::table('permission_role')->insert(
23
-                [
24
-                'permission_id' => $permission->id,
25
-                'role_id'       => $adminRoleId,
26
-                'created_at'    => \DB::raw('NOW()'),
27
-                'updated_at'    => \DB::raw('NOW()')
28
-                ]
29
-            );
30
-        });
31
-    }
18
+		/**
19
+		 * Assign the permissions to the admin role.
20
+		 */
21
+		\DB::table('permissions')->orderBy('created_at', 'asc')->whereIn('model', ['user'])->each(function ($permission) use ($adminRoleId) {
22
+			\DB::table('permission_role')->insert(
23
+				[
24
+				'permission_id' => $permission->id,
25
+				'role_id'       => $adminRoleId,
26
+				'created_at'    => \DB::raw('NOW()'),
27
+				'updated_at'    => \DB::raw('NOW()')
28
+				]
29
+			);
30
+		});
31
+	}
32 32
 }
Please login to merge, or discard this patch.
src/Modules/Users/Database/Seeds/ClearDataSeeder.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -6,15 +6,15 @@
 block discarded – undo
6 6
 
7 7
 class ClearDataSeeder extends Seeder
8 8
 {
9
-    /**
10
-     * Run the database seeds.
11
-     *
12
-     * @return void
13
-     */
14
-    public function run()
15
-    {
16
-        $permissions = \DB::table('permissions')->whereIn('model', ['user']);
17
-        \DB::table('permission_role')->whereIn('permission_id', $permissions->pluck('id'))->delete();
18
-        $permissions->delete();
19
-    }
9
+	/**
10
+	 * Run the database seeds.
11
+	 *
12
+	 * @return void
13
+	 */
14
+	public function run()
15
+	{
16
+		$permissions = \DB::table('permissions')->whereIn('model', ['user']);
17
+		\DB::table('permission_role')->whereIn('permission_id', $permissions->pluck('id'))->delete();
18
+		$permissions->delete();
19
+	}
20 20
 }
Please login to merge, or discard this patch.
src/Modules/Users/AclUser.php 1 patch
Indentation   +127 added lines, -127 removed lines patch added patch discarded remove patch
@@ -10,133 +10,133 @@
 block discarded – undo
10 10
 class AclUser extends User
11 11
 {
12 12
 
13
-    use SoftDeletes, HasApiTokens;
14
-    protected $table    = 'users';
15
-    protected $dates    = ['created_at', 'updated_at', 'deleted_at'];
16
-    protected $hidden   = ['password', 'remember_token', 'deleted_at'];
17
-    protected $guarded  = ['id'];
18
-    protected $fillable = ['profile_picture', 'name', 'email', 'password', 'locale', 'timezone'];
19
-    public $searchable  = ['name', 'email'];
13
+	use SoftDeletes, HasApiTokens;
14
+	protected $table    = 'users';
15
+	protected $dates    = ['created_at', 'updated_at', 'deleted_at'];
16
+	protected $hidden   = ['password', 'remember_token', 'deleted_at'];
17
+	protected $guarded  = ['id'];
18
+	protected $fillable = ['profile_picture', 'name', 'email', 'password', 'locale', 'timezone'];
19
+	public $searchable  = ['name', 'email'];
20 20
     
21
-    public function getCreatedAtAttribute($value)
22
-    {
23
-        return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
24
-    }
25
-
26
-    public function getUpdatedAtAttribute($value)
27
-    {
28
-        return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
29
-    }
30
-
31
-    public function getDeletedAtAttribute($value)
32
-    {
33
-        return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
34
-    }
35
-
36
-    /**
37
-     * Get the profile picture url.
38
-     * @return string
39
-     */
40
-    public function getProfilePictureAttribute($value)
41
-    {
42
-        return url(\Storage::url($value));
43
-    }
44
-
45
-    /**
46
-     * Encrypt the password attribute before
47
-     * saving it in the storage.
48
-     *
49
-     * @param string $value
50
-     */
51
-    public function setPasswordAttribute($value)
52
-    {
53
-        $this->attributes['password'] = \Hash::make($value);
54
-    }
55
-
56
-    /**
57
-     * Get the entity's notifications.
58
-     */
59
-    public function notifications()
60
-    {
61
-        return $this->morphMany(Notification::class, 'notifiable')->orderBy('created_at', 'desc');
62
-    }
63
-
64
-    /**
65
-     * Get the entity's read notifications.
66
-     */
67
-    public function readNotifications()
68
-    {
69
-        return $this->notifications()->whereNotNull('read_at');
70
-    }
71
-
72
-    /**
73
-     * Get the entity's unread notifications.
74
-     */
75
-    public function unreadNotifications()
76
-    {
77
-        return $this->notifications()->whereNull('read_at');
78
-    }
79
-
80
-    public function roles()
81
-    {
82
-        return $this->belongsToMany(Role::class, 'role_user', 'user_id', 'role_id')->whereNull('role_user.deleted_at')->withTimestamps();
83
-    }
84
-
85
-    public function oauthClients()
86
-    {
87
-        return $this->hasMany(OauthClient::class, 'user_id');
88
-    }
89
-
90
-    /**
91
-     * Return fcm device tokens that will be used in sending fcm notifications.
92
-     *
93
-     * @return array
94
-     */
95
-    public function routeNotificationForFCM()
96
-    {
97
-        $devices = \Core::pushNotificationDevices()->findBy(['user_id' => $this->id]);
98
-        $tokens  = [];
99
-
100
-        foreach ($devices as $device) {
101
-            if (\Core::oauthClients()->accessTokenExpiredOrRevoked($device->access_token)) {
102
-                $device->forceDelete();
103
-                continue;
104
-            }
105
-
106
-            $tokens[] = $device->device_token;
107
-        }
108
-
109
-        return $tokens;
110
-    }
111
-
112
-    /**
113
-     * The channels the user receives notification broadcasts on.
114
-     *
115
-     * @return string
116
-     */
117
-    public function receivesBroadcastNotificationsOn()
118
-    {
119
-        return 'users.'.$this->id;
120
-    }
121
-
122
-    /**
123
-     * Custom password validation.
124
-     *
125
-     * @param  string $password
126
-     * @return boolean
127
-     */
128
-    public function validateForPassportPasswordGrant($password)
129
-    {
130
-        if ($password == config('skeleton.social_pass')) {
131
-            return true;
132
-        }
133
-
134
-        return \Hash::check($password, $this->password);
135
-    }
21
+	public function getCreatedAtAttribute($value)
22
+	{
23
+		return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
24
+	}
25
+
26
+	public function getUpdatedAtAttribute($value)
27
+	{
28
+		return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
29
+	}
30
+
31
+	public function getDeletedAtAttribute($value)
32
+	{
33
+		return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
34
+	}
35
+
36
+	/**
37
+	 * Get the profile picture url.
38
+	 * @return string
39
+	 */
40
+	public function getProfilePictureAttribute($value)
41
+	{
42
+		return url(\Storage::url($value));
43
+	}
44
+
45
+	/**
46
+	 * Encrypt the password attribute before
47
+	 * saving it in the storage.
48
+	 *
49
+	 * @param string $value
50
+	 */
51
+	public function setPasswordAttribute($value)
52
+	{
53
+		$this->attributes['password'] = \Hash::make($value);
54
+	}
55
+
56
+	/**
57
+	 * Get the entity's notifications.
58
+	 */
59
+	public function notifications()
60
+	{
61
+		return $this->morphMany(Notification::class, 'notifiable')->orderBy('created_at', 'desc');
62
+	}
63
+
64
+	/**
65
+	 * Get the entity's read notifications.
66
+	 */
67
+	public function readNotifications()
68
+	{
69
+		return $this->notifications()->whereNotNull('read_at');
70
+	}
71
+
72
+	/**
73
+	 * Get the entity's unread notifications.
74
+	 */
75
+	public function unreadNotifications()
76
+	{
77
+		return $this->notifications()->whereNull('read_at');
78
+	}
79
+
80
+	public function roles()
81
+	{
82
+		return $this->belongsToMany(Role::class, 'role_user', 'user_id', 'role_id')->whereNull('role_user.deleted_at')->withTimestamps();
83
+	}
84
+
85
+	public function oauthClients()
86
+	{
87
+		return $this->hasMany(OauthClient::class, 'user_id');
88
+	}
89
+
90
+	/**
91
+	 * Return fcm device tokens that will be used in sending fcm notifications.
92
+	 *
93
+	 * @return array
94
+	 */
95
+	public function routeNotificationForFCM()
96
+	{
97
+		$devices = \Core::pushNotificationDevices()->findBy(['user_id' => $this->id]);
98
+		$tokens  = [];
99
+
100
+		foreach ($devices as $device) {
101
+			if (\Core::oauthClients()->accessTokenExpiredOrRevoked($device->access_token)) {
102
+				$device->forceDelete();
103
+				continue;
104
+			}
105
+
106
+			$tokens[] = $device->device_token;
107
+		}
108
+
109
+		return $tokens;
110
+	}
111
+
112
+	/**
113
+	 * The channels the user receives notification broadcasts on.
114
+	 *
115
+	 * @return string
116
+	 */
117
+	public function receivesBroadcastNotificationsOn()
118
+	{
119
+		return 'users.'.$this->id;
120
+	}
121
+
122
+	/**
123
+	 * Custom password validation.
124
+	 *
125
+	 * @param  string $password
126
+	 * @return boolean
127
+	 */
128
+	public function validateForPassportPasswordGrant($password)
129
+	{
130
+		if ($password == config('skeleton.social_pass')) {
131
+			return true;
132
+		}
133
+
134
+		return \Hash::check($password, $this->password);
135
+	}
136 136
     
137
-    public static function boot()
138
-    {
139
-        parent::boot();
140
-        AclUser::observe(\App::make('App\Modules\Users\ModelObservers\AclUserObserver'));
141
-    }
137
+	public static function boot()
138
+	{
139
+		parent::boot();
140
+		AclUser::observe(\App::make('App\Modules\Users\ModelObservers\AclUserObserver'));
141
+	}
142 142
 }
Please login to merge, or discard this patch.
src/Modules/Users/Reppsitories/UserRepository.php 1 patch
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -6,52 +6,52 @@
 block discarded – undo
6 6
 
7 7
 class UserRepository extends BaseRepository
8 8
 {
9
-    /**
10
-     * Init new object.
11
-     *
12
-     * @param   AclUser $model
13
-     * @return  void
14
-     */
15
-    public function __construct(AclUser $model)
16
-    {
17
-        parent::__construct($model);
18
-    }
9
+	/**
10
+	 * Init new object.
11
+	 *
12
+	 * @param   AclUser $model
13
+	 * @return  void
14
+	 */
15
+	public function __construct(AclUser $model)
16
+	{
17
+		parent::__construct($model);
18
+	}
19 19
 
20
-    /**
21
-     * Detach all roles from the given role.
22
-     *
23
-     * @param  mixed $role
24
-     * @return object
25
-     */
26
-    public function detachRoles($role)
27
-    {
28
-        $role = ! is_int($role) ? $role : $this->find($role);
29
-        $role->roles()->detach();
30
-    }
20
+	/**
21
+	 * Detach all roles from the given role.
22
+	 *
23
+	 * @param  mixed $role
24
+	 * @return object
25
+	 */
26
+	public function detachRoles($role)
27
+	{
28
+		$role = ! is_int($role) ? $role : $this->find($role);
29
+		$role->roles()->detach();
30
+	}
31 31
 
32
-    /**
33
-     * Attach role ids to the given role.
34
-     *
35
-     * @param  mixed $role
36
-     * @param  array $roleIds
37
-     * @return object
38
-     */
39
-    public function attachRoles($role, $roleIds)
40
-    {
41
-        $role = ! is_int($role) ? $role : $this->find($role);
42
-        $role->roles()->attach($roleIds);
43
-    }
32
+	/**
33
+	 * Attach role ids to the given role.
34
+	 *
35
+	 * @param  mixed $role
36
+	 * @param  array $roleIds
37
+	 * @return object
38
+	 */
39
+	public function attachRoles($role, $roleIds)
40
+	{
41
+		$role = ! is_int($role) ? $role : $this->find($role);
42
+		$role->roles()->attach($roleIds);
43
+	}
44 44
 
45
-    /**
46
-     * Count the given user the given roles.
47
-     *
48
-     * @param  mixed    $user
49
-     * @param  string[] $roles
50
-     * @return boolean
51
-     */
52
-    public function countRoles($user, $roles)
53
-    {
54
-        $user = ! is_int($user) ? $user : $this->find($user);
55
-        return $user->roles()->whereIn('name', $roles)->count();
56
-    }
45
+	/**
46
+	 * Count the given user the given roles.
47
+	 *
48
+	 * @param  mixed    $user
49
+	 * @param  string[] $roles
50
+	 * @return boolean
51
+	 */
52
+	public function countRoles($user, $roles)
53
+	{
54
+		$user = ! is_int($user) ? $user : $this->find($user);
55
+		return $user->roles()->whereIn('name', $roles)->count();
56
+	}
57 57
 }
Please login to merge, or discard this patch.
src/Modules/Users/Http/Controllers/UserController.php 1 patch
Indentation   +221 added lines, -221 removed lines patch added patch discarded remove patch
@@ -24,225 +24,225 @@
 block discarded – undo
24 24
 
25 25
 class UserController extends BaseApiController
26 26
 {
27
-    /**
28
-     * Path of the model resource
29
-     *
30
-     * @var string
31
-     */
32
-    protected $modelResource = 'App\Modules\Users\Http\Resources\AclUser';
33
-
34
-    /**
35
-     * List of all route actions that the base api controller
36
-     * will skip permissions check for them.
37
-     * @var array
38
-     */
39
-    protected $skipPermissionCheck = ['account', 'logout', 'changePassword', 'saveProfile'];
40
-
41
-    /**
42
-     * List of all route actions that the base api controller
43
-     * will skip login check for them.
44
-     * @var array
45
-     */
46
-    protected $skipLoginCheck = ['login', 'loginSocial', 'register', 'sendReset', 'resetPassword', 'refreshToken', 'confirmEmail', 'resendEmailConfirmation'];
47
-
48
-    /**
49
-     * Init new object.
50
-     *
51
-     * @param   UserService $service
52
-     * @return  void
53
-     */
54
-    public function __construct(UserService $service)
55
-    {
56
-        parent::__construct($service);
57
-    }
58
-
59
-    /**
60
-     * Insert the given model to storage.
61
-     *
62
-     * @param InsertUser $request
63
-     * @return \Illuminate\Http\Response
64
-     */
65
-    public function insert(InsertUser $request)
66
-    {
67
-        return new $this->modelResource($this->service->save($request->all()));
68
-    }
69
-
70
-    /**
71
-     * Update the given model to storage.
72
-     *
73
-     * @param UpdateUser $request
74
-     * @return \Illuminate\Http\Response
75
-     */
76
-    public function update(UpdateUser $request)
77
-    {
78
-        return new $this->modelResource($this->service->save($request->all()));
79
-    }
80
-
81
-    /**
82
-     * Return the logged in user account.
83
-     *
84
-     * @param Request $request
85
-     * @return \Illuminate\Http\Response
86
-     */
87
-    public function account(Request $request)
88
-    {
89
-        return new $this->modelResource($this->service->account($request->relations));
90
-    }
91
-
92
-    /**
93
-     * Block the user.
94
-     *
95
-     * @param  integer  $id Id of the user.
96
-     * @return \Illuminate\Http\Response
97
-     */
98
-    public function block($id)
99
-    {
100
-        return new $this->modelResource($this->service->block($id));
101
-    }
102
-
103
-    /**
104
-     * Unblock the user.
105
-     *
106
-     * @param  integer  $id Id of the user.
107
-     * @return \Illuminate\Http\Response
108
-     */
109
-    public function unblock($id)
110
-    {
111
-        return new $this->modelResource($this->service->unblock($id));
112
-    }
113
-
114
-    /**
115
-     * Logout the user.
116
-     *
117
-     * @return \Illuminate\Http\Response
118
-     */
119
-    public function logout()
120
-    {
121
-        return new GeneralResource($this->service->logout());
122
-    }
123
-
124
-    /**
125
-     * Handle a registration request.
126
-     *
127
-     * @param Register $request
128
-     * @return \Illuminate\Http\Response
129
-     */
130
-    public function register(Register $request)
131
-    {
132
-        return new $this->modelResource($this->service->register($request->get('name'), $request->get('email'), $request->get('password')));
133
-    }
134
-
135
-    /**
136
-     * Handle a login request to the application.
137
-     *
138
-     * @param Login $request
139
-     * @return \Illuminate\Http\Response
140
-     */
141
-    public function login(Login $request)
142
-    {
143
-        $result = $this->service->login($request->get('email'), $request->get('password'), $request->get('admin'));
144
-
145
-        return (new $this->modelResource($result['user']))->additional(['meta' => $result['tokens']]);
146
-    }
147
-
148
-    /**
149
-     * Handle a social login request of the none admin to the application.
150
-     *
151
-     * @param LoginSocial $request
152
-     * @return \Illuminate\Http\Response
153
-     */
154
-    public function loginSocial(LoginSocial $request)
155
-    {
156
-        $result = $this->service->loginSocial($request->get('auth_code'), $request->get('access_token'), $request->get('type'));
157
-
158
-        return (new $this->modelResource($result['user']))->additional(['meta' => $result['tokens']]);
159
-    }
160
-
161
-    /**
162
-     * Assign the given roles to the given user.
163
-     *
164
-     * @param AssignRoles $request
165
-     * @return \Illuminate\Http\Response
166
-     */
167
-    public function assignRoles(AssignRoles $request)
168
-    {
169
-        return new $this->modelResource($this->service->assignRoles($request->get('user_id'), $request->get('role_ids')));
170
-    }
171
-
172
-    /**
173
-     * Send a reset link to the given user.
174
-     *
175
-     * @param SendReset $request
176
-     * @return \Illuminate\Http\Response
177
-     */
178
-    public function sendReset(SendReset $request)
179
-    {
180
-        return new GeneralResource($this->service->sendReset($request->get('email')));
181
-    }
182
-
183
-    /**
184
-     * Reset the given user's password.
185
-     *
186
-     * @param ResetPassword $request
187
-     * @return \Illuminate\Http\Response
188
-     */
189
-    public function resetPassword(ResetPassword $request)
190
-    {
191
-        return new GeneralResource($this->service->resetPassword($request->get('email'), $request->get('password'), $request->get('password_confirmation'), $request->get('token')));
192
-    }
193
-
194
-    /**
195
-     * Change the logged in user password.
196
-     *
197
-     * @param ChangePassword $request
198
-     * @return \Illuminate\Http\Response
199
-     */
200
-    public function changePassword(ChangePassword $request)
201
-    {
202
-        return new GeneralResource($this->service->changePassword($request->get('password') , $request->get('old_password')));
203
-    }
204
-
205
-    /**
206
-     * Confirm email using the confirmation code.
207
-     *
208
-     * @param ConfirmEmail $request
209
-     * @return \Illuminate\Http\Response
210
-     */
211
-    public function confirmEmail(ConfirmEmail $request)
212
-    {
213
-        return new GeneralResource($this->service->confirmEmail($request->only('confirmation_code')));
214
-    }
215
-
216
-    /**
217
-     * Resend the email confirmation mail.
218
-     *
219
-     * @param ResendEmailConfirmation $request
220
-     * @return \Illuminate\Http\Response
221
-     */
222
-    public function resendEmailConfirmation(ResendEmailConfirmation $request)
223
-    {
224
-        return new GeneralResource($this->service->sendConfirmationEmail($request->get('email')));
225
-    }
226
-
227
-    /**
228
-     * Refresh the expired login token.
229
-     *
230
-     * @param RefreshToken $request
231
-     * @return \Illuminate\Http\Response
232
-     */
233
-    public function refreshToken(RefreshToken $request)
234
-    {
235
-        return new GeneralResource($this->service->refreshToken($request->get('refresh_token')));
236
-    }
237
-
238
-    /**
239
-     * Save the given data to the logged in user.
240
-     *
241
-     * @param SaveProfile $request
242
-     * @return \Illuminate\Http\Response
243
-     */
244
-    public function saveProfile(SaveProfile $request)
245
-    {
246
-        return new $this->modelResource($this->service->saveProfile($request->get('name'), $request->get('email'), $request->get('profile_picture')));
247
-    }
27
+	/**
28
+	 * Path of the model resource
29
+	 *
30
+	 * @var string
31
+	 */
32
+	protected $modelResource = 'App\Modules\Users\Http\Resources\AclUser';
33
+
34
+	/**
35
+	 * List of all route actions that the base api controller
36
+	 * will skip permissions check for them.
37
+	 * @var array
38
+	 */
39
+	protected $skipPermissionCheck = ['account', 'logout', 'changePassword', 'saveProfile'];
40
+
41
+	/**
42
+	 * List of all route actions that the base api controller
43
+	 * will skip login check for them.
44
+	 * @var array
45
+	 */
46
+	protected $skipLoginCheck = ['login', 'loginSocial', 'register', 'sendReset', 'resetPassword', 'refreshToken', 'confirmEmail', 'resendEmailConfirmation'];
47
+
48
+	/**
49
+	 * Init new object.
50
+	 *
51
+	 * @param   UserService $service
52
+	 * @return  void
53
+	 */
54
+	public function __construct(UserService $service)
55
+	{
56
+		parent::__construct($service);
57
+	}
58
+
59
+	/**
60
+	 * Insert the given model to storage.
61
+	 *
62
+	 * @param InsertUser $request
63
+	 * @return \Illuminate\Http\Response
64
+	 */
65
+	public function insert(InsertUser $request)
66
+	{
67
+		return new $this->modelResource($this->service->save($request->all()));
68
+	}
69
+
70
+	/**
71
+	 * Update the given model to storage.
72
+	 *
73
+	 * @param UpdateUser $request
74
+	 * @return \Illuminate\Http\Response
75
+	 */
76
+	public function update(UpdateUser $request)
77
+	{
78
+		return new $this->modelResource($this->service->save($request->all()));
79
+	}
80
+
81
+	/**
82
+	 * Return the logged in user account.
83
+	 *
84
+	 * @param Request $request
85
+	 * @return \Illuminate\Http\Response
86
+	 */
87
+	public function account(Request $request)
88
+	{
89
+		return new $this->modelResource($this->service->account($request->relations));
90
+	}
91
+
92
+	/**
93
+	 * Block the user.
94
+	 *
95
+	 * @param  integer  $id Id of the user.
96
+	 * @return \Illuminate\Http\Response
97
+	 */
98
+	public function block($id)
99
+	{
100
+		return new $this->modelResource($this->service->block($id));
101
+	}
102
+
103
+	/**
104
+	 * Unblock the user.
105
+	 *
106
+	 * @param  integer  $id Id of the user.
107
+	 * @return \Illuminate\Http\Response
108
+	 */
109
+	public function unblock($id)
110
+	{
111
+		return new $this->modelResource($this->service->unblock($id));
112
+	}
113
+
114
+	/**
115
+	 * Logout the user.
116
+	 *
117
+	 * @return \Illuminate\Http\Response
118
+	 */
119
+	public function logout()
120
+	{
121
+		return new GeneralResource($this->service->logout());
122
+	}
123
+
124
+	/**
125
+	 * Handle a registration request.
126
+	 *
127
+	 * @param Register $request
128
+	 * @return \Illuminate\Http\Response
129
+	 */
130
+	public function register(Register $request)
131
+	{
132
+		return new $this->modelResource($this->service->register($request->get('name'), $request->get('email'), $request->get('password')));
133
+	}
134
+
135
+	/**
136
+	 * Handle a login request to the application.
137
+	 *
138
+	 * @param Login $request
139
+	 * @return \Illuminate\Http\Response
140
+	 */
141
+	public function login(Login $request)
142
+	{
143
+		$result = $this->service->login($request->get('email'), $request->get('password'), $request->get('admin'));
144
+
145
+		return (new $this->modelResource($result['user']))->additional(['meta' => $result['tokens']]);
146
+	}
147
+
148
+	/**
149
+	 * Handle a social login request of the none admin to the application.
150
+	 *
151
+	 * @param LoginSocial $request
152
+	 * @return \Illuminate\Http\Response
153
+	 */
154
+	public function loginSocial(LoginSocial $request)
155
+	{
156
+		$result = $this->service->loginSocial($request->get('auth_code'), $request->get('access_token'), $request->get('type'));
157
+
158
+		return (new $this->modelResource($result['user']))->additional(['meta' => $result['tokens']]);
159
+	}
160
+
161
+	/**
162
+	 * Assign the given roles to the given user.
163
+	 *
164
+	 * @param AssignRoles $request
165
+	 * @return \Illuminate\Http\Response
166
+	 */
167
+	public function assignRoles(AssignRoles $request)
168
+	{
169
+		return new $this->modelResource($this->service->assignRoles($request->get('user_id'), $request->get('role_ids')));
170
+	}
171
+
172
+	/**
173
+	 * Send a reset link to the given user.
174
+	 *
175
+	 * @param SendReset $request
176
+	 * @return \Illuminate\Http\Response
177
+	 */
178
+	public function sendReset(SendReset $request)
179
+	{
180
+		return new GeneralResource($this->service->sendReset($request->get('email')));
181
+	}
182
+
183
+	/**
184
+	 * Reset the given user's password.
185
+	 *
186
+	 * @param ResetPassword $request
187
+	 * @return \Illuminate\Http\Response
188
+	 */
189
+	public function resetPassword(ResetPassword $request)
190
+	{
191
+		return new GeneralResource($this->service->resetPassword($request->get('email'), $request->get('password'), $request->get('password_confirmation'), $request->get('token')));
192
+	}
193
+
194
+	/**
195
+	 * Change the logged in user password.
196
+	 *
197
+	 * @param ChangePassword $request
198
+	 * @return \Illuminate\Http\Response
199
+	 */
200
+	public function changePassword(ChangePassword $request)
201
+	{
202
+		return new GeneralResource($this->service->changePassword($request->get('password') , $request->get('old_password')));
203
+	}
204
+
205
+	/**
206
+	 * Confirm email using the confirmation code.
207
+	 *
208
+	 * @param ConfirmEmail $request
209
+	 * @return \Illuminate\Http\Response
210
+	 */
211
+	public function confirmEmail(ConfirmEmail $request)
212
+	{
213
+		return new GeneralResource($this->service->confirmEmail($request->only('confirmation_code')));
214
+	}
215
+
216
+	/**
217
+	 * Resend the email confirmation mail.
218
+	 *
219
+	 * @param ResendEmailConfirmation $request
220
+	 * @return \Illuminate\Http\Response
221
+	 */
222
+	public function resendEmailConfirmation(ResendEmailConfirmation $request)
223
+	{
224
+		return new GeneralResource($this->service->sendConfirmationEmail($request->get('email')));
225
+	}
226
+
227
+	/**
228
+	 * Refresh the expired login token.
229
+	 *
230
+	 * @param RefreshToken $request
231
+	 * @return \Illuminate\Http\Response
232
+	 */
233
+	public function refreshToken(RefreshToken $request)
234
+	{
235
+		return new GeneralResource($this->service->refreshToken($request->get('refresh_token')));
236
+	}
237
+
238
+	/**
239
+	 * Save the given data to the logged in user.
240
+	 *
241
+	 * @param SaveProfile $request
242
+	 * @return \Illuminate\Http\Response
243
+	 */
244
+	public function saveProfile(SaveProfile $request)
245
+	{
246
+		return new $this->modelResource($this->service->saveProfile($request->get('name'), $request->get('email'), $request->get('profile_picture')));
247
+	}
248 248
 }
Please login to merge, or discard this patch.
src/Modules/Users/Proxy/LoginProxy.php 1 patch
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -5,64 +5,64 @@
 block discarded – undo
5 5
 
6 6
 class LoginProxy
7 7
 {
8
-    /**
9
-     * Attempt to create an access token using user credentials.
10
-     *
11
-     * @param  string  $email
12
-     * @param  string  $password
13
-     * @return array
14
-     */
15
-    public function login($email, $password)
16
-    {
17
-        return $this->proxy('password', [
18
-            'username' => $email,
19
-            'password' => $password
20
-        ]);
21
-    }
8
+	/**
9
+	 * Attempt to create an access token using user credentials.
10
+	 *
11
+	 * @param  string  $email
12
+	 * @param  string  $password
13
+	 * @return array
14
+	 */
15
+	public function login($email, $password)
16
+	{
17
+		return $this->proxy('password', [
18
+			'username' => $email,
19
+			'password' => $password
20
+		]);
21
+	}
22 22
 
23
-    /**
24
-     * Attempt to refresh the access token using the given refresh token.
25
-     *
26
-     * @param  string $refreshToken
27
-     * @return array
28
-     */
29
-    public function refreshToken($refreshToken)
30
-    {
31
-        return $this->proxy('refresh_token', [
32
-            'refresh_token' => $refreshToken
33
-        ]);
34
-    }
23
+	/**
24
+	 * Attempt to refresh the access token using the given refresh token.
25
+	 *
26
+	 * @param  string $refreshToken
27
+	 * @return array
28
+	 */
29
+	public function refreshToken($refreshToken)
30
+	{
31
+		return $this->proxy('refresh_token', [
32
+			'refresh_token' => $refreshToken
33
+		]);
34
+	}
35 35
 
36
-    /**
37
-     * Proxy a request to the OAuth server.
38
-     *
39
-     * @param string $grantType what type of grant type should be proxied
40
-     * @param array
41
-     */
42
-    public function proxy($grantType, array $data = [])
43
-    {
44
-        $data = array_merge($data, [
45
-            'client_id'     => config('skeleton.passport_client_id'),
46
-            'client_secret' => config('skeleton.passport_client_secret'),
47
-            'grant_type'    => $grantType
48
-        ]);
36
+	/**
37
+	 * Proxy a request to the OAuth server.
38
+	 *
39
+	 * @param string $grantType what type of grant type should be proxied
40
+	 * @param array
41
+	 */
42
+	public function proxy($grantType, array $data = [])
43
+	{
44
+		$data = array_merge($data, [
45
+			'client_id'     => config('skeleton.passport_client_id'),
46
+			'client_secret' => config('skeleton.passport_client_secret'),
47
+			'grant_type'    => $grantType
48
+		]);
49 49
 
50
-        $response = \ApiConsumer::post('/oauth/token', $data);
50
+		$response = \ApiConsumer::post('/oauth/token', $data);
51 51
 
52
-        if (! $response->isSuccessful()) {
53
-            if ($grantType == 'refresh_token') {
54
-                \ErrorHandler::invalidRefreshToken();
55
-            }
52
+		if (! $response->isSuccessful()) {
53
+			if ($grantType == 'refresh_token') {
54
+				\ErrorHandler::invalidRefreshToken();
55
+			}
56 56
 
57
-            \ErrorHandler::loginFailed();
58
-        }
57
+			\ErrorHandler::loginFailed();
58
+		}
59 59
 
60
-        $data = json_decode($response->getContent());
60
+		$data = json_decode($response->getContent());
61 61
 
62
-        return [
63
-            'access_token'  => $data->access_token,
64
-            'refresh_token' => $data->refresh_token,
65
-            'expires_in'    => $data->expires_in
66
-        ];
67
-    }
62
+		return [
63
+			'access_token'  => $data->access_token,
64
+			'refresh_token' => $data->refresh_token,
65
+			'expires_in'    => $data->expires_in
66
+		];
67
+	}
68 68
 }
Please login to merge, or discard this patch.