Completed
Push — master ( de5c78...60eb24 )
by Sherif
09:23
created
src/Modules/Notifications/Services/NotificationService.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@
 block discarded – undo
66 66
      *
67 67
      * @param  collection $users
68 68
      * @param  string     $notification
69
-     * @param  Variadic   $notificationData
69
+     * @param  Variadic[]   $notificationData
70 70
      * @return void
71 71
      */
72 72
     public function notify($users, $notification, ...$notificationData)
Please login to merge, or discard this patch.
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -7,72 +7,72 @@
 block discarded – undo
7 7
 
8 8
 class NotificationService extends BaseService
9 9
 {
10
-    /**
11
-     * Init new object.
12
-     *
13
-     * @param   NotificationRepository $repo
14
-     * @return  void
15
-     */
16
-    public function __construct(NotificationRepository $repo)
17
-    {
18
-        parent::__construct($repo);
19
-    }
10
+	/**
11
+	 * Init new object.
12
+	 *
13
+	 * @param   NotificationRepository $repo
14
+	 * @return  void
15
+	 */
16
+	public function __construct(NotificationRepository $repo)
17
+	{
18
+		parent::__construct($repo);
19
+	}
20 20
 
21
-    /**
22
-     * Retrieve all notifications of the logged in user.
23
-     *
24
-     * @param  integer $perPage
25
-     * @return Collection
26
-     */
27
-    public function my($perPage)
28
-    {
29
-        return $this->repo->my($perPage);
30
-    }
21
+	/**
22
+	 * Retrieve all notifications of the logged in user.
23
+	 *
24
+	 * @param  integer $perPage
25
+	 * @return Collection
26
+	 */
27
+	public function my($perPage)
28
+	{
29
+		return $this->repo->my($perPage);
30
+	}
31 31
 
32
-    /**
33
-     * Retrieve unread notifications of the logged in user.
34
-     *
35
-     * @param  integer $perPage
36
-     * @return Collection
37
-     */
38
-    public function unread($perPage)
39
-    {
40
-        return $this->repo->unread($perPage);
41
-    }
32
+	/**
33
+	 * Retrieve unread notifications of the logged in user.
34
+	 *
35
+	 * @param  integer $perPage
36
+	 * @return Collection
37
+	 */
38
+	public function unread($perPage)
39
+	{
40
+		return $this->repo->unread($perPage);
41
+	}
42 42
 
43
-    /**
44
-     * Mark the notification as read.
45
-     *
46
-     * @param  integer  $id
47
-     * @return object
48
-     */
49
-    public function markAsRead($id)
50
-    {
51
-        return $this->repo->markAsRead($id);
52
-    }
43
+	/**
44
+	 * Mark the notification as read.
45
+	 *
46
+	 * @param  integer  $id
47
+	 * @return object
48
+	 */
49
+	public function markAsRead($id)
50
+	{
51
+		return $this->repo->markAsRead($id);
52
+	}
53 53
 
54
-    /**
55
-     * Mark all notifications as read.
56
-     *
57
-     * @return void
58
-     */
59
-    public function markAllAsRead()
60
-    {
61
-        return $this->repo->markAllAsRead();
62
-    }
54
+	/**
55
+	 * Mark all notifications as read.
56
+	 *
57
+	 * @return void
58
+	 */
59
+	public function markAllAsRead()
60
+	{
61
+		return $this->repo->markAllAsRead();
62
+	}
63 63
 
64
-    /**
65
-     * Notify th given user with the given notification.
66
-     *
67
-     * @param  collection $users
68
-     * @param  string     $notification
69
-     * @param  Variadic   $notificationData
70
-     * @return void
71
-     */
72
-    public function notify($users, $notification, ...$notificationData)
73
-    {
74
-        $users = is_array($users) ? $this->userRepo->findBy(['id' => ['op' => 'in', 'val' => $users]]) : $users;
75
-        $notification = 'App\Modules\Notifications\Notifications\\'.$notification;
76
-        \Notification::send($users, new $notification(...$notificationData));
77
-    }
64
+	/**
65
+	 * Notify th given user with the given notification.
66
+	 *
67
+	 * @param  collection $users
68
+	 * @param  string     $notification
69
+	 * @param  Variadic   $notificationData
70
+	 * @return void
71
+	 */
72
+	public function notify($users, $notification, ...$notificationData)
73
+	{
74
+		$users = is_array($users) ? $this->userRepo->findBy(['id' => ['op' => 'in', 'val' => $users]]) : $users;
75
+		$notification = 'App\Modules\Notifications\Notifications\\'.$notification;
76
+		\Notification::send($users, new $notification(...$notificationData));
77
+	}
78 78
 }
Please login to merge, or discard this patch.
Modules/PushNotificationDevices/Services/PushNotificationDeviceService.php 2 patches
Unused Use Statements   -3 removed lines patch added patch discarded remove patch
@@ -3,9 +3,6 @@
 block discarded – undo
3 3
 namespace App\Modules\PushNotificationDevices\Services;
4 4
 
5 5
 use App\Modules\Core\BaseClasses\BaseService;
6
-use LaravelFCM\Message\OptionsBuilder;
7
-use LaravelFCM\Message\PayloadDataBuilder;
8
-use LaravelFCM\Message\PayloadNotificationBuilder;
9 6
 use App\Modules\PushNotificationDevices\Repositories\PushNotificationDeviceRepository;
10 7
 
11 8
 class PushNotificationDeviceService extends BaseService
Please login to merge, or discard this patch.
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -10,38 +10,38 @@
 block discarded – undo
10 10
 
11 11
 class PushNotificationDeviceService extends BaseService
12 12
 {
13
-    /**
14
-     * Init new object.
15
-     *
16
-     * @param   PushNotificationDeviceRepository $repo
17
-     * @return  void
18
-     */
19
-    public function __construct(PushNotificationDeviceRepository $repo)
20
-    {
21
-        parent::__construct($repo);
22
-    }
13
+	/**
14
+	 * Init new object.
15
+	 *
16
+	 * @param   PushNotificationDeviceRepository $repo
17
+	 * @return  void
18
+	 */
19
+	public function __construct(PushNotificationDeviceRepository $repo)
20
+	{
21
+		parent::__construct($repo);
22
+	}
23 23
 
24
-    /**
25
-     * Register the given device to the logged in user.
26
-     *
27
-     * @param  array $data
28
-     * @return void
29
-     */
30
-    public function registerDevice($data)
31
-    {
32
-        $data['access_token'] = \Auth::user()->token();
33
-        $data['user_id']      = \Auth::id();
34
-        $device               = $this->repo->first([
35
-            'and' => [
36
-                'device_token' => $data['device_token'],
37
-                'user_id' => $data['user_id']
38
-                ]
39
-            ]);
24
+	/**
25
+	 * Register the given device to the logged in user.
26
+	 *
27
+	 * @param  array $data
28
+	 * @return void
29
+	 */
30
+	public function registerDevice($data)
31
+	{
32
+		$data['access_token'] = \Auth::user()->token();
33
+		$data['user_id']      = \Auth::id();
34
+		$device               = $this->repo->first([
35
+			'and' => [
36
+				'device_token' => $data['device_token'],
37
+				'user_id' => $data['user_id']
38
+				]
39
+			]);
40 40
 
41
-        if ($device) {
42
-            $data['id'] = $device->id;
43
-        }
41
+		if ($device) {
42
+			$data['id'] = $device->id;
43
+		}
44 44
 
45
-        return $this->repo->save($data);
46
-    }
45
+		return $this->repo->save($data);
46
+	}
47 47
 }
Please login to merge, or discard this patch.
src/Modules/Reporting/Repositories/ReportRepository.php 1 patch
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -7,45 +7,45 @@
 block discarded – undo
7 7
 
8 8
 class ReportRepository extends BaseRepository
9 9
 {
10
-    /**
11
-     * Init new object.
12
-     *
13
-     * @param   Report $model
14
-     * @return  void
15
-     */
16
-    public function __construct(Report $model)
17
-    {
18
-        parent::__construct($model);
19
-    }
10
+	/**
11
+	 * Init new object.
12
+	 *
13
+	 * @param   Report $model
14
+	 * @return  void
15
+	 */
16
+	public function __construct(Report $model)
17
+	{
18
+		parent::__construct($model);
19
+	}
20 20
 
21
-    /**
22
-     * Render the given report db view based on the given
23
-     * condition.
24
-     *
25
-     * @param  mixed   $report
26
-     * @param  array   $conditions
27
-     * @param  integer $perPage
28
-     * @return object
29
-     */
30
-    public function renderReport($report, $conditions = [], $perPage = 0)
31
-    {
32
-        $report = ! filter_var($report, FILTER_VALIDATE_INT) ? $report : $this->find($report);
33
-        /**
34
-         * Fetch data from the report based on the given conditions.
35
-         */
36
-        $report = \DB::table($report->view_name);
37
-        unset($conditions['page']);
38
-        if (count($conditions)) {
39
-            $conditions = $this->constructConditions($conditions, $this->model);
40
-            $report->whereRaw($conditions['conditionString'], $conditions['conditionValues']);
41
-        }
42
-        /**
43
-         * Paginate or all data.
44
-         */
45
-        if ($perPage) {
46
-            return $report->paginate($perPage);
47
-        } else {
48
-            return $report->get();
49
-        }
50
-    }
21
+	/**
22
+	 * Render the given report db view based on the given
23
+	 * condition.
24
+	 *
25
+	 * @param  mixed   $report
26
+	 * @param  array   $conditions
27
+	 * @param  integer $perPage
28
+	 * @return object
29
+	 */
30
+	public function renderReport($report, $conditions = [], $perPage = 0)
31
+	{
32
+		$report = ! filter_var($report, FILTER_VALIDATE_INT) ? $report : $this->find($report);
33
+		/**
34
+		 * Fetch data from the report based on the given conditions.
35
+		 */
36
+		$report = \DB::table($report->view_name);
37
+		unset($conditions['page']);
38
+		if (count($conditions)) {
39
+			$conditions = $this->constructConditions($conditions, $this->model);
40
+			$report->whereRaw($conditions['conditionString'], $conditions['conditionValues']);
41
+		}
42
+		/**
43
+		 * Paginate or all data.
44
+		 */
45
+		if ($perPage) {
46
+			return $report->paginate($perPage);
47
+		} else {
48
+			return $report->get();
49
+		}
50
+	}
51 51
 }
Please login to merge, or discard this patch.
src/Modules/Users/Http/Requests/Register.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 Register extends FormRequest
8 8
 {
9
-    /**
10
-     * Determine if the user is authorized to make this request.
11
-     *
12
-     * @return bool
13
-     */
14
-    public function authorize()
15
-    {
16
-        return true;
17
-    }
9
+	/**
10
+	 * Determine if the user is authorized to make this request.
11
+	 *
12
+	 * @return bool
13
+	 */
14
+	public function authorize()
15
+	{
16
+		return true;
17
+	}
18 18
 
19
-    /**
20
-     * Get the validation rules that apply to the request.
21
-     *
22
-     * @return array
23
-     */
24
-    public function rules()
25
-    {
26
-        return [
27
-            'name'     => 'nullable|string',
28
-            'email'    => 'required|email|unique:users,email',
29
-            'password' => 'required|min:6'
30
-        ];
31
-    }
19
+	/**
20
+	 * Get the validation rules that apply to the request.
21
+	 *
22
+	 * @return array
23
+	 */
24
+	public function rules()
25
+	{
26
+		return [
27
+			'name'     => 'nullable|string',
28
+			'email'    => 'required|email|unique:users,email',
29
+			'password' => 'required|min:6'
30
+		];
31
+	}
32 32
 }
Please login to merge, or discard this patch.
src/Modules/Users/Http/Requests/StoreUser.php 2 patches
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 StoreUser extends FormRequest
8 8
 {
9
-    /**
10
-     * Determine if the user is authorized to make this request.
11
-     *
12
-     * @return bool
13
-     */
14
-    public function authorize()
15
-    {
16
-        return true;
17
-    }
9
+	/**
10
+	 * Determine if the user is authorized to make this request.
11
+	 *
12
+	 * @return bool
13
+	 */
14
+	public function authorize()
15
+	{
16
+		return true;
17
+	}
18 18
 
19
-    /**
20
-     * Get the validation rules that apply to the request.
21
-     *
22
-     * @return array
23
-     */
24
-    public function rules()
25
-    {
26
-        return [
27
-            'name'     => 'nullable|string',
28
-            'email'    => 'required|email|unique:users,email,' . $this->route('id'),
29
-            'password' => 'nullable|min:6'
30
-        ];
31
-    }
19
+	/**
20
+	 * Get the validation rules that apply to the request.
21
+	 *
22
+	 * @return array
23
+	 */
24
+	public function rules()
25
+	{
26
+		return [
27
+			'name'     => 'nullable|string',
28
+			'email'    => 'required|email|unique:users,email,' . $this->route('id'),
29
+			'password' => 'nullable|min:6'
30
+		];
31
+	}
32 32
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@
 block discarded – undo
25 25
     {
26 26
         return [
27 27
             'name'     => 'nullable|string',
28
-            'email'    => 'required|email|unique:users,email,' . $this->route('id'),
28
+            'email'    => 'required|email|unique:users,email,'.$this->route('id'),
29 29
             'password' => 'nullable|min:6'
30 30
         ];
31 31
     }
Please login to merge, or discard this patch.
src/Modules/Users/Http/Requests/AssignRoles.php 1 patch
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -6,26 +6,26 @@
 block discarded – undo
6 6
 
7 7
 class AssignRoles extends FormRequest
8 8
 {
9
-    /**
10
-     * Determine if the user is authorized to make this request.
11
-     *
12
-     * @return bool
13
-     */
14
-    public function authorize()
15
-    {
16
-        return true;
17
-    }
9
+	/**
10
+	 * Determine if the user is authorized to make this request.
11
+	 *
12
+	 * @return bool
13
+	 */
14
+	public function authorize()
15
+	{
16
+		return true;
17
+	}
18 18
 
19
-    /**
20
-     * Get the validation rules that apply to the request.
21
-     *
22
-     * @return array
23
-     */
24
-    public function rules()
25
-    {
26
-        return [
27
-            'role_ids' => 'required|array',
28
-            'role_ids.*' => 'required|exists:roles,id'
29
-        ];
30
-    }
19
+	/**
20
+	 * Get the validation rules that apply to the request.
21
+	 *
22
+	 * @return array
23
+	 */
24
+	public function rules()
25
+	{
26
+		return [
27
+			'role_ids' => 'required|array',
28
+			'role_ids.*' => 'required|exists:roles,id'
29
+		];
30
+	}
31 31
 }
Please login to merge, or discard this patch.
src/Modules/Users/Database/Seeds/UsersTableSeeder.php 2 patches
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::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::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'       => 'show',
57
-                'model'      => 'user',
58
-                'created_at' => \DB::raw('NOW()'),
59
-                'updated_at' => \DB::raw('NOW()')
60
-                ],
61
-                [
62
-                'name'       => 'store',
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'       => 'destroy',
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'       => 'show',
57
+				'model'      => 'user',
58
+				'created_at' => \DB::raw('NOW()'),
59
+				'updated_at' => \DB::raw('NOW()')
60
+				],
61
+				[
62
+				'name'       => 'store',
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'       => 'destroy',
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.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
          */
21 21
         Role::updateOrInsert([
22 22
             'name' => 'Admin',
23
-        ],[
23
+        ], [
24 24
             'created_at' => \DB::raw('NOW()'),
25 25
             'updated_at' => \DB::raw('NOW()')
26 26
         ]);
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
          */
31 31
         AclUser::updateOrInsert([
32 32
             'email' => '[email protected]',
33
-        ],[
33
+        ], [
34 34
             'name'       => 'Admin',
35 35
             'password'   => \Hash::make('123456'),
36 36
             'confirmed'  => 1,
Please login to merge, or discard this patch.
src/Modules/Users/Services/UserService.php 2 patches
Indentation   +361 added lines, -361 removed lines patch added patch discarded remove patch
@@ -12,368 +12,368 @@
 block discarded – undo
12 12
 
13 13
 class UserService extends BaseService
14 14
 {
15
-    /**
16
-     * @var PermissionService
17
-     */
18
-    protected $permissionService;
19
-
20
-    /**
21
-     * @var LoginProxy
22
-     */
23
-    protected $loginProxy;
24
-
25
-    /**
26
-     * @var NotificationService
27
-     */
28
-    protected $notificationService;
29
-
30
-    /**
31
-     * @var OauthClientService
32
-     */
33
-    protected $oauthClientService;
34
-
35
-    /**
36
-     * Init new object.
37
-     *
38
-     * @param   UserRepository       $repo
39
-     * @param   PermissionService    $permissionService
40
-     * @param   LoginProxy           $loginProxy
41
-     * @param   NotificationService  $notificationService
42
-     * @param   OauthClientService   $oauthClientService
43
-     * @return  void
44
-     */
45
-    public function __construct(
46
-        UserRepository $repo,
47
-        PermissionService $permissionService,
48
-        LoginProxy $loginProxy,
49
-        NotificationService $notificationService,
50
-        OauthClientService $oauthClientService
51
-    ) {
52
-        $this->permissionService   = $permissionService;
53
-        $this->loginProxy          = $loginProxy;
54
-        $this->notificationService = $notificationService;
55
-        $this->oauthClientService  = $oauthClientService;
56
-        parent::__construct($repo);
57
-    }
58
-
59
-    /**
60
-     * Return the logged in user account.
61
-     *
62
-     * @param  array   $relations
63
-     * @return boolean
64
-     */
65
-    public function account($relations = ['roles.permissions'])
66
-    {
67
-        $permissions = [];
68
-        $user        = $this->repo->find(\Auth::id(), $relations);
69
-        foreach ($user->roles as $role) {
70
-            $role->permissions->each(function ($permission) use (&$permissions) {
71
-                $permissions[$permission->repo][$permission->id] = $permission->name;
72
-            });
73
-        }
74
-        $user->permissions = $permissions;
75
-
76
-        return $user;
77
-    }
78
-
79
-    /**
80
-     * Check if the logged in user or the given user
81
-     * has the given permissions on the given model.
82
-     *
83
-     * @param  string $permissionName
84
-     * @param  string $model
85
-     * @param  mixed  $userId
86
-     * @return boolean
87
-     */
88
-    public function can($permissionName, $model, $userId = false)
89
-    {
90
-        $permission = $this->permissionService->first([
91
-            'and' => [
92
-                'model' => $model,
93
-                'name'  => $permissionName,
94
-                'roles' => [
95
-                    'op' => 'has',
96
-                    'val' => [
97
-                        'users' => [
98
-                            'op' => 'has',
99
-                            'val' => [
100
-                                'users.id' => $userId ?: \Auth::id()
101
-                            ]
102
-                        ]
103
-                    ]
104
-                ]
105
-            ]
106
-        ]);
107
-
108
-        return $permission ? true : false;
109
-    }
110
-
111
-    /**
112
-     * Check if the logged in or the given user has the given role.
113
-     *
114
-     * @param  string[] $roles
115
-     * @param  mixed    $user
116
-     * @return boolean
117
-     */
118
-    public function hasRoles($roles, $user = false)
119
-    {
120
-        return $this->repo->countRoles($user ?: \Auth::id(), $roles) ? true : false;
121
-    }
122
-
123
-    /**
124
-     * Assign the given role ids to the given user.
125
-     *
126
-     * @param  integer $userId
127
-     * @param  array   $roleIds
128
-     * @return object
129
-     */
130
-    public function assignRoles($userId, $roleIds)
131
-    {
132
-        $user = false;
133
-        \DB::transaction(function () use ($userId, $roleIds, &$user) {
134
-            $user = $this->repo->find($userId);
135
-            $this->repo->detachRoles($user);
136
-            $this->repo->attachRoles($user, $roleIds);
137
-        });
138
-
139
-        return $user;
140
-    }
141
-
142
-    /**
143
-     * Handle the login request to the application.
144
-     *
145
-     * @param  string  $email
146
-     * @param  string  $password
147
-     * @return object
148
-     */
149
-    public function login($email, $password)
150
-    {
151
-        if (! $user = $this->repo->first(['email' => $email])) {
152
-            \Errors::loginFailed();
153
-        } elseif ($user->blocked) {
154
-            \Errors::userIsBlocked();
155
-        } elseif (! config('user.disable_confirm_email') && ! $user->confirmed) {
156
-            \Errors::emailNotConfirmed();
157
-        }
158
-
159
-        return ['user' => $user, 'tokens' => $this->loginProxy->login($user->email, $password)];
160
-    }
161
-
162
-    /**
163
-     * Handle the social login request to the application.
164
-     *
165
-     * @param  string $authCode
166
-     * @param  string $accessToken
167
-     * @return array
168
-     */
169
-    public function loginSocial($authCode, $accessToken, $type)
170
-    {
171
-        $accessToken = $authCode ? Arr::get(\Socialite::driver($type)->getAccessTokenResponse($authCode), 'access_token') : $accessToken;
172
-        $user        = \Socialite::driver($type)->userFromToken($accessToken)->user;
173
-
174
-        if (! \Arr::has($user, 'email')) {
175
-            \Errors::noSocialEmail();
176
-        }
177
-
178
-        if (! $this->repo->first(['email' => $user['email']])) {
179
-            $this->register($user['name'], $user['email'], '', true);
180
-        }
181
-
182
-        return $this->login($user['email'], config('user.social_pass'));
183
-    }
15
+	/**
16
+	 * @var PermissionService
17
+	 */
18
+	protected $permissionService;
19
+
20
+	/**
21
+	 * @var LoginProxy
22
+	 */
23
+	protected $loginProxy;
24
+
25
+	/**
26
+	 * @var NotificationService
27
+	 */
28
+	protected $notificationService;
29
+
30
+	/**
31
+	 * @var OauthClientService
32
+	 */
33
+	protected $oauthClientService;
34
+
35
+	/**
36
+	 * Init new object.
37
+	 *
38
+	 * @param   UserRepository       $repo
39
+	 * @param   PermissionService    $permissionService
40
+	 * @param   LoginProxy           $loginProxy
41
+	 * @param   NotificationService  $notificationService
42
+	 * @param   OauthClientService   $oauthClientService
43
+	 * @return  void
44
+	 */
45
+	public function __construct(
46
+		UserRepository $repo,
47
+		PermissionService $permissionService,
48
+		LoginProxy $loginProxy,
49
+		NotificationService $notificationService,
50
+		OauthClientService $oauthClientService
51
+	) {
52
+		$this->permissionService   = $permissionService;
53
+		$this->loginProxy          = $loginProxy;
54
+		$this->notificationService = $notificationService;
55
+		$this->oauthClientService  = $oauthClientService;
56
+		parent::__construct($repo);
57
+	}
58
+
59
+	/**
60
+	 * Return the logged in user account.
61
+	 *
62
+	 * @param  array   $relations
63
+	 * @return boolean
64
+	 */
65
+	public function account($relations = ['roles.permissions'])
66
+	{
67
+		$permissions = [];
68
+		$user        = $this->repo->find(\Auth::id(), $relations);
69
+		foreach ($user->roles as $role) {
70
+			$role->permissions->each(function ($permission) use (&$permissions) {
71
+				$permissions[$permission->repo][$permission->id] = $permission->name;
72
+			});
73
+		}
74
+		$user->permissions = $permissions;
75
+
76
+		return $user;
77
+	}
78
+
79
+	/**
80
+	 * Check if the logged in user or the given user
81
+	 * has the given permissions on the given model.
82
+	 *
83
+	 * @param  string $permissionName
84
+	 * @param  string $model
85
+	 * @param  mixed  $userId
86
+	 * @return boolean
87
+	 */
88
+	public function can($permissionName, $model, $userId = false)
89
+	{
90
+		$permission = $this->permissionService->first([
91
+			'and' => [
92
+				'model' => $model,
93
+				'name'  => $permissionName,
94
+				'roles' => [
95
+					'op' => 'has',
96
+					'val' => [
97
+						'users' => [
98
+							'op' => 'has',
99
+							'val' => [
100
+								'users.id' => $userId ?: \Auth::id()
101
+							]
102
+						]
103
+					]
104
+				]
105
+			]
106
+		]);
107
+
108
+		return $permission ? true : false;
109
+	}
110
+
111
+	/**
112
+	 * Check if the logged in or the given user has the given role.
113
+	 *
114
+	 * @param  string[] $roles
115
+	 * @param  mixed    $user
116
+	 * @return boolean
117
+	 */
118
+	public function hasRoles($roles, $user = false)
119
+	{
120
+		return $this->repo->countRoles($user ?: \Auth::id(), $roles) ? true : false;
121
+	}
122
+
123
+	/**
124
+	 * Assign the given role ids to the given user.
125
+	 *
126
+	 * @param  integer $userId
127
+	 * @param  array   $roleIds
128
+	 * @return object
129
+	 */
130
+	public function assignRoles($userId, $roleIds)
131
+	{
132
+		$user = false;
133
+		\DB::transaction(function () use ($userId, $roleIds, &$user) {
134
+			$user = $this->repo->find($userId);
135
+			$this->repo->detachRoles($user);
136
+			$this->repo->attachRoles($user, $roleIds);
137
+		});
138
+
139
+		return $user;
140
+	}
141
+
142
+	/**
143
+	 * Handle the login request to the application.
144
+	 *
145
+	 * @param  string  $email
146
+	 * @param  string  $password
147
+	 * @return object
148
+	 */
149
+	public function login($email, $password)
150
+	{
151
+		if (! $user = $this->repo->first(['email' => $email])) {
152
+			\Errors::loginFailed();
153
+		} elseif ($user->blocked) {
154
+			\Errors::userIsBlocked();
155
+		} elseif (! config('user.disable_confirm_email') && ! $user->confirmed) {
156
+			\Errors::emailNotConfirmed();
157
+		}
158
+
159
+		return ['user' => $user, 'tokens' => $this->loginProxy->login($user->email, $password)];
160
+	}
161
+
162
+	/**
163
+	 * Handle the social login request to the application.
164
+	 *
165
+	 * @param  string $authCode
166
+	 * @param  string $accessToken
167
+	 * @return array
168
+	 */
169
+	public function loginSocial($authCode, $accessToken, $type)
170
+	{
171
+		$accessToken = $authCode ? Arr::get(\Socialite::driver($type)->getAccessTokenResponse($authCode), 'access_token') : $accessToken;
172
+		$user        = \Socialite::driver($type)->userFromToken($accessToken)->user;
173
+
174
+		if (! \Arr::has($user, 'email')) {
175
+			\Errors::noSocialEmail();
176
+		}
177
+
178
+		if (! $this->repo->first(['email' => $user['email']])) {
179
+			$this->register($user['name'], $user['email'], '', true);
180
+		}
181
+
182
+		return $this->login($user['email'], config('user.social_pass'));
183
+	}
184 184
     
185
-    /**
186
-     * Handle the registration request.
187
-     *
188
-     * @param  string  $name
189
-     * @param  string  $email
190
-     * @param  string  $password
191
-     * @param  boolean $skipConfirmEmail
192
-     * @return array
193
-     */
194
-    public function register($name, $email, $password, $skipConfirmEmail = false)
195
-    {
196
-        $user = $this->repo->save([
197
-            'name'      => $name,
198
-            'email'     => $email,
199
-            'password'  => $password,
200
-            'confirmed' => $skipConfirmEmail
201
-        ]);
202
-
203
-        if (! $skipConfirmEmail && ! config('user.disable_confirm_email')) {
204
-            $this->sendConfirmationEmail($user->email);
205
-        }
206
-
207
-        return $user;
208
-    }
185
+	/**
186
+	 * Handle the registration request.
187
+	 *
188
+	 * @param  string  $name
189
+	 * @param  string  $email
190
+	 * @param  string  $password
191
+	 * @param  boolean $skipConfirmEmail
192
+	 * @return array
193
+	 */
194
+	public function register($name, $email, $password, $skipConfirmEmail = false)
195
+	{
196
+		$user = $this->repo->save([
197
+			'name'      => $name,
198
+			'email'     => $email,
199
+			'password'  => $password,
200
+			'confirmed' => $skipConfirmEmail
201
+		]);
202
+
203
+		if (! $skipConfirmEmail && ! config('user.disable_confirm_email')) {
204
+			$this->sendConfirmationEmail($user->email);
205
+		}
206
+
207
+		return $user;
208
+	}
209 209
     
210
-    /**
211
-     * Block the user.
212
-     *
213
-     * @param  integer $userId
214
-     * @return object
215
-     */
216
-    public function block($userId)
217
-    {
218
-        if (\Auth::id() == $userId) {
219
-            \Errors::noPermissions();
220
-        }
210
+	/**
211
+	 * Block the user.
212
+	 *
213
+	 * @param  integer $userId
214
+	 * @return object
215
+	 */
216
+	public function block($userId)
217
+	{
218
+		if (\Auth::id() == $userId) {
219
+			\Errors::noPermissions();
220
+		}
221 221
         
222
-        return $this->repo->save(['id' => $userId, 'blocked' => 1]);
223
-    }
224
-
225
-    /**
226
-     * Unblock the user.
227
-     *
228
-     * @param  integer $userId
229
-     * @return object
230
-     */
231
-    public function unblock($userId)
232
-    {
233
-        return $this->repo->save(['id' => $userId, 'blocked' => 0]);
234
-    }
235
-
236
-    /**
237
-     * Send a reset link to the given user.
238
-     *
239
-     * @param  string  $email
240
-     * @return void
241
-     */
242
-    public function sendReset($email)
243
-    {
244
-        if (! $user = $this->repo->first(['email' => $email])) {
245
-            \Errors::notFound('email');
246
-        }
247
-
248
-        $token = \Password::createToken($user);
249
-        $this->notificationService->notify($user, 'ResetPassword', $token);
250
-    }
251
-
252
-    /**
253
-     * Reset the given user's password.
254
-     *
255
-     * @param   string  $email
256
-     * @param   string  $password
257
-     * @param   string  $passwordConfirmation
258
-     * @param   string  $token
259
-     * @return string|void
260
-     */
261
-    public function resetPassword($email, $password, $passwordConfirmation, $token)
262
-    {
263
-        $response = \Password::reset([
264
-            'email'                 => $email,
265
-            'password'              => $password,
266
-            'password_confirmation' => $passwordConfirmation,
267
-            'token'                 => $token
268
-        ], function ($user, $password) {
269
-            $this->repo->save(['id' => $user->id, 'password' => $password]);
270
-        });
271
-
272
-        switch ($response) {
273
-            case \Password::PASSWORD_RESET:
274
-                return 'success';
275
-                break;
276
-
277
-            case \Password::INVALID_TOKEN:
278
-                \Errors::invalidResetToken();
279
-                break;
280
-
281
-            case \Password::INVALID_PASSWORD:
282
-                \Errors::invalidResetPassword();
283
-                break;
284
-
285
-            case \Password::INVALID_USER:
286
-                \Errors::notFound('user');
287
-                break;
288
-        }
289
-    }
290
-
291
-    /**
292
-     * Change the logged in user password.
293
-     *
294
-     * @param  string  $password
295
-     * @param  string  $oldPassword
296
-     * @return void
297
-     */
298
-    public function changePassword($password, $oldPassword)
299
-    {
300
-        $user = \Auth::user();
301
-        if (! \Hash::check($oldPassword, $user->password)) {
302
-            \Errors::invalidOldPassword();
303
-        }
304
-
305
-        $this->repo->save(['id' => $user->id, 'password' => $password]);
306
-    }
307
-
308
-    /**
309
-     * Confirm email using the confirmation code.
310
-     *
311
-     * @param  string $confirmationCode
312
-     * @return void
313
-     */
314
-    public function confirmEmail($confirmationCode)
315
-    {
316
-        if (! $user = $this->repo->first(['confirmation_code' => $confirmationCode])) {
317
-            \Errors::invalidConfirmationCode();
318
-        }
319
-
320
-        $this->repo->save(['id' => $user->id, 'confirmed' => 1, 'confirmation_code' => null]);
321
-    }
322
-
323
-    /**
324
-     * Send the confirmation mail.
325
-     *
326
-     * @param  string $email
327
-     * @return void
328
-     */
329
-    public function sendConfirmationEmail($email)
330
-    {
331
-        $user = $this->repo->first(['email' => $email]);
332
-        if ($user->confirmed) {
333
-            \Errors::emailAlreadyConfirmed();
334
-        }
335
-
336
-        $this->repo->save(['id' => $user->id, 'confirmation_code' => sha1(microtime())]);
337
-        $this->notificationService->notify($user, 'ConfirmEmail');
338
-    }
339
-
340
-    /**
341
-     * Save the given data to the logged in user.
342
-     *
343
-     * @param  string $name
344
-     * @param  string $email
345
-     * @param  string $profilePicture
346
-     * @return void
347
-     */
348
-    public function saveProfile($name, $email, $profilePicture = false)
349
-    {
350
-        $data['id'] = \Auth::id();
351
-        return $this->repo->save([
352
-            'id'             => \Auth::id(),
353
-            'name'           => $name,
354
-            'email'          => $email,
355
-            'profilePicture' => $profilePicture,
356
-        ]);
357
-    }
358
-
359
-    /**
360
-     * Logs out the user, revoke access token and refresh token.
361
-     *
362
-     * @return void
363
-     */
364
-    public function logout()
365
-    {
366
-        $this->oauthClientService->revokeAccessToken(\Auth::user()->token());
367
-    }
368
-
369
-    /**
370
-     * Attempt to refresh the access token using the given refresh token.
371
-     *
372
-     * @param  string $refreshToken
373
-     * @return array
374
-     */
375
-    public function refreshToken($refreshToken)
376
-    {
377
-        return $this->loginProxy->refreshToken($refreshToken);
378
-    }
222
+		return $this->repo->save(['id' => $userId, 'blocked' => 1]);
223
+	}
224
+
225
+	/**
226
+	 * Unblock the user.
227
+	 *
228
+	 * @param  integer $userId
229
+	 * @return object
230
+	 */
231
+	public function unblock($userId)
232
+	{
233
+		return $this->repo->save(['id' => $userId, 'blocked' => 0]);
234
+	}
235
+
236
+	/**
237
+	 * Send a reset link to the given user.
238
+	 *
239
+	 * @param  string  $email
240
+	 * @return void
241
+	 */
242
+	public function sendReset($email)
243
+	{
244
+		if (! $user = $this->repo->first(['email' => $email])) {
245
+			\Errors::notFound('email');
246
+		}
247
+
248
+		$token = \Password::createToken($user);
249
+		$this->notificationService->notify($user, 'ResetPassword', $token);
250
+	}
251
+
252
+	/**
253
+	 * Reset the given user's password.
254
+	 *
255
+	 * @param   string  $email
256
+	 * @param   string  $password
257
+	 * @param   string  $passwordConfirmation
258
+	 * @param   string  $token
259
+	 * @return string|void
260
+	 */
261
+	public function resetPassword($email, $password, $passwordConfirmation, $token)
262
+	{
263
+		$response = \Password::reset([
264
+			'email'                 => $email,
265
+			'password'              => $password,
266
+			'password_confirmation' => $passwordConfirmation,
267
+			'token'                 => $token
268
+		], function ($user, $password) {
269
+			$this->repo->save(['id' => $user->id, 'password' => $password]);
270
+		});
271
+
272
+		switch ($response) {
273
+			case \Password::PASSWORD_RESET:
274
+				return 'success';
275
+				break;
276
+
277
+			case \Password::INVALID_TOKEN:
278
+				\Errors::invalidResetToken();
279
+				break;
280
+
281
+			case \Password::INVALID_PASSWORD:
282
+				\Errors::invalidResetPassword();
283
+				break;
284
+
285
+			case \Password::INVALID_USER:
286
+				\Errors::notFound('user');
287
+				break;
288
+		}
289
+	}
290
+
291
+	/**
292
+	 * Change the logged in user password.
293
+	 *
294
+	 * @param  string  $password
295
+	 * @param  string  $oldPassword
296
+	 * @return void
297
+	 */
298
+	public function changePassword($password, $oldPassword)
299
+	{
300
+		$user = \Auth::user();
301
+		if (! \Hash::check($oldPassword, $user->password)) {
302
+			\Errors::invalidOldPassword();
303
+		}
304
+
305
+		$this->repo->save(['id' => $user->id, 'password' => $password]);
306
+	}
307
+
308
+	/**
309
+	 * Confirm email using the confirmation code.
310
+	 *
311
+	 * @param  string $confirmationCode
312
+	 * @return void
313
+	 */
314
+	public function confirmEmail($confirmationCode)
315
+	{
316
+		if (! $user = $this->repo->first(['confirmation_code' => $confirmationCode])) {
317
+			\Errors::invalidConfirmationCode();
318
+		}
319
+
320
+		$this->repo->save(['id' => $user->id, 'confirmed' => 1, 'confirmation_code' => null]);
321
+	}
322
+
323
+	/**
324
+	 * Send the confirmation mail.
325
+	 *
326
+	 * @param  string $email
327
+	 * @return void
328
+	 */
329
+	public function sendConfirmationEmail($email)
330
+	{
331
+		$user = $this->repo->first(['email' => $email]);
332
+		if ($user->confirmed) {
333
+			\Errors::emailAlreadyConfirmed();
334
+		}
335
+
336
+		$this->repo->save(['id' => $user->id, 'confirmation_code' => sha1(microtime())]);
337
+		$this->notificationService->notify($user, 'ConfirmEmail');
338
+	}
339
+
340
+	/**
341
+	 * Save the given data to the logged in user.
342
+	 *
343
+	 * @param  string $name
344
+	 * @param  string $email
345
+	 * @param  string $profilePicture
346
+	 * @return void
347
+	 */
348
+	public function saveProfile($name, $email, $profilePicture = false)
349
+	{
350
+		$data['id'] = \Auth::id();
351
+		return $this->repo->save([
352
+			'id'             => \Auth::id(),
353
+			'name'           => $name,
354
+			'email'          => $email,
355
+			'profilePicture' => $profilePicture,
356
+		]);
357
+	}
358
+
359
+	/**
360
+	 * Logs out the user, revoke access token and refresh token.
361
+	 *
362
+	 * @return void
363
+	 */
364
+	public function logout()
365
+	{
366
+		$this->oauthClientService->revokeAccessToken(\Auth::user()->token());
367
+	}
368
+
369
+	/**
370
+	 * Attempt to refresh the access token using the given refresh token.
371
+	 *
372
+	 * @param  string $refreshToken
373
+	 * @return array
374
+	 */
375
+	public function refreshToken($refreshToken)
376
+	{
377
+		return $this->loginProxy->refreshToken($refreshToken);
378
+	}
379 379
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
         $permissions = [];
68 68
         $user        = $this->repo->find(\Auth::id(), $relations);
69 69
         foreach ($user->roles as $role) {
70
-            $role->permissions->each(function ($permission) use (&$permissions) {
70
+            $role->permissions->each(function($permission) use (&$permissions) {
71 71
                 $permissions[$permission->repo][$permission->id] = $permission->name;
72 72
             });
73 73
         }
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
     public function assignRoles($userId, $roleIds)
131 131
     {
132 132
         $user = false;
133
-        \DB::transaction(function () use ($userId, $roleIds, &$user) {
133
+        \DB::transaction(function() use ($userId, $roleIds, &$user) {
134 134
             $user = $this->repo->find($userId);
135 135
             $this->repo->detachRoles($user);
136 136
             $this->repo->attachRoles($user, $roleIds);
@@ -148,11 +148,11 @@  discard block
 block discarded – undo
148 148
      */
149 149
     public function login($email, $password)
150 150
     {
151
-        if (! $user = $this->repo->first(['email' => $email])) {
151
+        if ( ! $user = $this->repo->first(['email' => $email])) {
152 152
             \Errors::loginFailed();
153 153
         } elseif ($user->blocked) {
154 154
             \Errors::userIsBlocked();
155
-        } elseif (! config('user.disable_confirm_email') && ! $user->confirmed) {
155
+        } elseif ( ! config('user.disable_confirm_email') && ! $user->confirmed) {
156 156
             \Errors::emailNotConfirmed();
157 157
         }
158 158
 
@@ -171,11 +171,11 @@  discard block
 block discarded – undo
171 171
         $accessToken = $authCode ? Arr::get(\Socialite::driver($type)->getAccessTokenResponse($authCode), 'access_token') : $accessToken;
172 172
         $user        = \Socialite::driver($type)->userFromToken($accessToken)->user;
173 173
 
174
-        if (! \Arr::has($user, 'email')) {
174
+        if ( ! \Arr::has($user, 'email')) {
175 175
             \Errors::noSocialEmail();
176 176
         }
177 177
 
178
-        if (! $this->repo->first(['email' => $user['email']])) {
178
+        if ( ! $this->repo->first(['email' => $user['email']])) {
179 179
             $this->register($user['name'], $user['email'], '', true);
180 180
         }
181 181
 
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
             'confirmed' => $skipConfirmEmail
201 201
         ]);
202 202
 
203
-        if (! $skipConfirmEmail && ! config('user.disable_confirm_email')) {
203
+        if ( ! $skipConfirmEmail && ! config('user.disable_confirm_email')) {
204 204
             $this->sendConfirmationEmail($user->email);
205 205
         }
206 206
 
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
      */
242 242
     public function sendReset($email)
243 243
     {
244
-        if (! $user = $this->repo->first(['email' => $email])) {
244
+        if ( ! $user = $this->repo->first(['email' => $email])) {
245 245
             \Errors::notFound('email');
246 246
         }
247 247
 
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
             'password'              => $password,
266 266
             'password_confirmation' => $passwordConfirmation,
267 267
             'token'                 => $token
268
-        ], function ($user, $password) {
268
+        ], function($user, $password) {
269 269
             $this->repo->save(['id' => $user->id, 'password' => $password]);
270 270
         });
271 271
 
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
     public function changePassword($password, $oldPassword)
299 299
     {
300 300
         $user = \Auth::user();
301
-        if (! \Hash::check($oldPassword, $user->password)) {
301
+        if ( ! \Hash::check($oldPassword, $user->password)) {
302 302
             \Errors::invalidOldPassword();
303 303
         }
304 304
 
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
      */
314 314
     public function confirmEmail($confirmationCode)
315 315
     {
316
-        if (! $user = $this->repo->first(['confirmation_code' => $confirmationCode])) {
316
+        if ( ! $user = $this->repo->first(['confirmation_code' => $confirmationCode])) {
317 317
             \Errors::invalidConfirmationCode();
318 318
         }
319 319
 
Please login to merge, or discard this patch.
src/Modules/Users/Repositories/UserRepository.php 1 patch
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -8,52 +8,52 @@
 block discarded – undo
8 8
 
9 9
 class UserRepository extends BaseRepository
10 10
 {
11
-    /**
12
-     * Init new object.
13
-     *
14
-     * @param   AclUser $model
15
-     * @return  void
16
-     */
17
-    public function __construct(AclUser $model)
18
-    {
19
-        parent::__construct($model);
20
-    }
11
+	/**
12
+	 * Init new object.
13
+	 *
14
+	 * @param   AclUser $model
15
+	 * @return  void
16
+	 */
17
+	public function __construct(AclUser $model)
18
+	{
19
+		parent::__construct($model);
20
+	}
21 21
 
22
-    /**
23
-     * Detach all roles from the given user.
24
-     *
25
-     * @param  mixed $user
26
-     * @return object
27
-     */
28
-    public function detachRoles($user)
29
-    {
30
-        $user = ! filter_var($user, FILTER_VALIDATE_INT) ? $user : $this->find($user);
31
-        $user->roles()->detach();
32
-    }
22
+	/**
23
+	 * Detach all roles from the given user.
24
+	 *
25
+	 * @param  mixed $user
26
+	 * @return object
27
+	 */
28
+	public function detachRoles($user)
29
+	{
30
+		$user = ! filter_var($user, FILTER_VALIDATE_INT) ? $user : $this->find($user);
31
+		$user->roles()->detach();
32
+	}
33 33
 
34
-    /**
35
-     * Attach role ids to the given user.
36
-     *
37
-     * @param  mixed $user
38
-     * @param  array $roleIds
39
-     * @return object
40
-     */
41
-    public function attachRoles($user, $roleIds)
42
-    {
43
-        $user = ! filter_var($user, FILTER_VALIDATE_INT) ? $user : $this->find($user);
44
-        $user->roles()->attach($roleIds);
45
-    }
34
+	/**
35
+	 * Attach role ids to the given user.
36
+	 *
37
+	 * @param  mixed $user
38
+	 * @param  array $roleIds
39
+	 * @return object
40
+	 */
41
+	public function attachRoles($user, $roleIds)
42
+	{
43
+		$user = ! filter_var($user, FILTER_VALIDATE_INT) ? $user : $this->find($user);
44
+		$user->roles()->attach($roleIds);
45
+	}
46 46
 
47
-    /**
48
-     * Count the given user the given roles.
49
-     *
50
-     * @param  mixed    $user
51
-     * @param  string[] $roles
52
-     * @return boolean
53
-     */
54
-    public function countRoles($user, $roles)
55
-    {
56
-        $user = ! filter_var($user, FILTER_VALIDATE_INT) ? $user : $this->find($user);
57
-        return $user->roles()->whereIn('name', $roles)->count();
58
-    }
47
+	/**
48
+	 * Count the given user the given roles.
49
+	 *
50
+	 * @param  mixed    $user
51
+	 * @param  string[] $roles
52
+	 * @return boolean
53
+	 */
54
+	public function countRoles($user, $roles)
55
+	{
56
+		$user = ! filter_var($user, FILTER_VALIDATE_INT) ? $user : $this->find($user);
57
+		return $user->roles()->whereIn('name', $roles)->count();
58
+	}
59 59
 }
Please login to merge, or discard this patch.