Completed
Push — master ( 8023d3...8b2ccd )
by Sherif
10:04
created
Database/Migrations/2016_06_01_000002_create_oauth_access_tokens_table.php 2 patches
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -6,35 +6,35 @@
 block discarded – undo
6 6
 
7 7
 class CreateOauthAccessTokensTable extends Migration
8 8
 {
9
-    /**
10
-     * Run the migrations.
11
-     *
12
-     * @return void
13
-     */
14
-    public function up()
15
-    {
16
-        Schema::create('oauth_access_tokens', function (Blueprint $table) {
17
-            $table->string('id', 100)->primary();
18
-            $table->unsignedInteger('user_id')->nullable();
19
-            $table->unsignedInteger('client_id');
20
-            $table->string('name')->nullable();
21
-            $table->text('scopes')->nullable();
22
-            $table->boolean('revoked');
23
-            $table->timestamps();
24
-            $table->dateTime('expires_at')->nullable();
9
+	/**
10
+	 * Run the migrations.
11
+	 *
12
+	 * @return void
13
+	 */
14
+	public function up()
15
+	{
16
+		Schema::create('oauth_access_tokens', function (Blueprint $table) {
17
+			$table->string('id', 100)->primary();
18
+			$table->unsignedInteger('user_id')->nullable();
19
+			$table->unsignedInteger('client_id');
20
+			$table->string('name')->nullable();
21
+			$table->text('scopes')->nullable();
22
+			$table->boolean('revoked');
23
+			$table->timestamps();
24
+			$table->dateTime('expires_at')->nullable();
25 25
 
26
-            $table->foreign('user_id')->references('id')->on('users');
27
-            $table->foreign('client_id')->references('id')->on('oauth_clients');
28
-        });
29
-    }
26
+			$table->foreign('user_id')->references('id')->on('users');
27
+			$table->foreign('client_id')->references('id')->on('oauth_clients');
28
+		});
29
+	}
30 30
 
31
-    /**
32
-     * Reverse the migrations.
33
-     *
34
-     * @return void
35
-     */
36
-    public function down()
37
-    {
38
-        Schema::drop('oauth_access_tokens');
39
-    }
31
+	/**
32
+	 * Reverse the migrations.
33
+	 *
34
+	 * @return void
35
+	 */
36
+	public function down()
37
+	{
38
+		Schema::drop('oauth_access_tokens');
39
+	}
40 40
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
      */
14 14
     public function up()
15 15
     {
16
-        Schema::create('oauth_access_tokens', function (Blueprint $table) {
16
+        Schema::create('oauth_access_tokens', function(Blueprint $table) {
17 17
             $table->string('id', 100)->primary();
18 18
             $table->unsignedInteger('user_id')->nullable();
19 19
             $table->unsignedInteger('client_id');
Please login to merge, or discard this patch.
Migrations/2016_06_01_000005_create_oauth_personal_access_clients_table.php 2 patches
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -6,29 +6,29 @@
 block discarded – undo
6 6
 
7 7
 class CreateOauthPersonalAccessClientsTable extends Migration
8 8
 {
9
-    /**
10
-     * Run the migrations.
11
-     *
12
-     * @return void
13
-     */
14
-    public function up()
15
-    {
16
-        Schema::create('oauth_personal_access_clients', function (Blueprint $table) {
17
-            $table->increments('id');
18
-            $table->unsignedInteger('client_id');
19
-            $table->timestamps();
9
+	/**
10
+	 * Run the migrations.
11
+	 *
12
+	 * @return void
13
+	 */
14
+	public function up()
15
+	{
16
+		Schema::create('oauth_personal_access_clients', function (Blueprint $table) {
17
+			$table->increments('id');
18
+			$table->unsignedInteger('client_id');
19
+			$table->timestamps();
20 20
             
21
-            $table->foreign('client_id')->references('id')->on('oauth_clients');
22
-        });
23
-    }
21
+			$table->foreign('client_id')->references('id')->on('oauth_clients');
22
+		});
23
+	}
24 24
 
25
-    /**
26
-     * Reverse the migrations.
27
-     *
28
-     * @return void
29
-     */
30
-    public function down()
31
-    {
32
-        Schema::drop('oauth_personal_access_clients');
33
-    }
25
+	/**
26
+	 * Reverse the migrations.
27
+	 *
28
+	 * @return void
29
+	 */
30
+	public function down()
31
+	{
32
+		Schema::drop('oauth_personal_access_clients');
33
+	}
34 34
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
      */
14 14
     public function up()
15 15
     {
16
-        Schema::create('oauth_personal_access_clients', function (Blueprint $table) {
16
+        Schema::create('oauth_personal_access_clients', function(Blueprint $table) {
17 17
             $table->increments('id');
18 18
             $table->unsignedInteger('client_id');
19 19
             $table->timestamps();
Please login to merge, or discard this patch.
src/Modules/Roles/Services/RoleService.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
21 21
      *
22 22
      * @param  integer $roleId
23 23
      * @param  array   $permissionIds
24
-     * @return object
24
+     * @return boolean
25 25
      */
26 26
     public function assignPermissions($roleId, $permissionIds)
27 27
     {
Please login to merge, or discard this patch.
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -5,33 +5,33 @@
 block discarded – undo
5 5
 
6 6
 class RoleService extends BaseService
7 7
 {
8
-    /**
9
-     * Init new object.
10
-     *
11
-     * @param   RoleRepository $repo
12
-     * @return  void
13
-     */
14
-    public function __construct(RoleRepository $repo)
15
-    {
16
-        parent::__construct($repo);
17
-    }
8
+	/**
9
+	 * Init new object.
10
+	 *
11
+	 * @param   RoleRepository $repo
12
+	 * @return  void
13
+	 */
14
+	public function __construct(RoleRepository $repo)
15
+	{
16
+		parent::__construct($repo);
17
+	}
18 18
 
19
-    /**
20
-     * Assign the given permission ids to the given role.
21
-     *
22
-     * @param  integer $roleId
23
-     * @param  array   $permissionIds
24
-     * @return object
25
-     */
26
-    public function assignPermissions($roleId, $permissionIds)
27
-    {
28
-        $role = false;
29
-        \DB::transaction(function () use ($roleId, $permissionIds, &$role) {
30
-            $role = $this->repo->find($roleId);
31
-            $this->repo->detachPermissions($roleId);
32
-            $this->repo->attachPermissions($roleId, $permissionIds);
33
-        });
19
+	/**
20
+	 * Assign the given permission ids to the given role.
21
+	 *
22
+	 * @param  integer $roleId
23
+	 * @param  array   $permissionIds
24
+	 * @return object
25
+	 */
26
+	public function assignPermissions($roleId, $permissionIds)
27
+	{
28
+		$role = false;
29
+		\DB::transaction(function () use ($roleId, $permissionIds, &$role) {
30
+			$role = $this->repo->find($roleId);
31
+			$this->repo->detachPermissions($roleId);
32
+			$this->repo->attachPermissions($roleId, $permissionIds);
33
+		});
34 34
 
35
-        return $role;
36
-    }
35
+		return $role;
36
+	}
37 37
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@
 block discarded – undo
26 26
     public function assignPermissions($roleId, $permissionIds)
27 27
     {
28 28
         $role = false;
29
-        \DB::transaction(function () use ($roleId, $permissionIds, &$role) {
29
+        \DB::transaction(function() use ($roleId, $permissionIds, &$role) {
30 30
             $role = $this->repo->find($roleId);
31 31
             $this->repo->detachPermissions($roleId);
32 32
             $this->repo->attachPermissions($roleId, $permissionIds);
Please login to merge, or discard this patch.
src/Modules/Users/Services/UserService.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -132,7 +132,7 @@
 block discarded – undo
132 132
      *
133 133
      * @param  integer $userId
134 134
      * @param  array   $roleIds
135
-     * @return object
135
+     * @return boolean
136 136
      */
137 137
     public function assignRoles($userId, $roleIds)
138 138
     {
Please login to merge, or discard this patch.
Indentation   +364 added lines, -364 removed lines patch added patch discarded remove patch
@@ -12,372 +12,372 @@
 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->detachPermissions($userId);
136
-            $this->repo->attachPermissions($userId, $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('skeleton.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
-        $access_token = $authCode ? Arr::get(\Socialite::driver($type)->getAccessTokenResponse($authCode), 'access_token') : $accessToken;
172
-        $user         = \Socialite::driver($type)->userFromToken($access_token);
173
-
174
-        if (! $user->email) {
175
-            \Errors::noSocialEmail();
176
-        }
177
-
178
-        if (! $this->repo->first(['email' => $user->email])) {
179
-            $this->register($user->email, '', true);
180
-        }
181
-
182
-        return $this->loginProxy->login($user->email, config('skeleton.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->detachPermissions($userId);
136
+			$this->repo->attachPermissions($userId, $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('skeleton.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
+		$access_token = $authCode ? Arr::get(\Socialite::driver($type)->getAccessTokenResponse($authCode), 'access_token') : $accessToken;
172
+		$user         = \Socialite::driver($type)->userFromToken($access_token);
173
+
174
+		if (! $user->email) {
175
+			\Errors::noSocialEmail();
176
+		}
177
+
178
+		if (! $this->repo->first(['email' => $user->email])) {
179
+			$this->register($user->email, '', true);
180
+		}
181
+
182
+		return $this->loginProxy->login($user->email, config('skeleton.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('skeleton.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('skeleton.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::getService()->create($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
-        if ($profilePicture) {
351
-            $data['profile_picture'] = \Media::uploadImageBas64($profilePicture, 'users/profile_pictures');
352
-        }
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::getService()->create($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
+		if ($profilePicture) {
351
+			$data['profile_picture'] = \Media::uploadImageBas64($profilePicture, 'users/profile_pictures');
352
+		}
353 353
         
354
-        $data['id'] = \Auth::id();
355
-        return $this->repo->save([
356
-            'id'             => \Auth::id(),
357
-            'name'           => $name,
358
-            'email'          => $email,
359
-            'profilePicture' => $profilePicture,
360
-        ]);
361
-    }
362
-
363
-    /**
364
-     * Logs out the user, revoke access token and refresh token.
365
-     *
366
-     * @return void
367
-     */
368
-    public function logout()
369
-    {
370
-        $this->oauthClientService->revokeAccessToken(\Auth::user()->token());
371
-    }
372
-
373
-    /**
374
-     * Attempt to refresh the access token using the given refresh token.
375
-     *
376
-     * @param  string $refreshToken
377
-     * @return array
378
-     */
379
-    public function refreshToken($refreshToken)
380
-    {
381
-        return $this->loginProxy->refreshToken($refreshToken);
382
-    }
354
+		$data['id'] = \Auth::id();
355
+		return $this->repo->save([
356
+			'id'             => \Auth::id(),
357
+			'name'           => $name,
358
+			'email'          => $email,
359
+			'profilePicture' => $profilePicture,
360
+		]);
361
+	}
362
+
363
+	/**
364
+	 * Logs out the user, revoke access token and refresh token.
365
+	 *
366
+	 * @return void
367
+	 */
368
+	public function logout()
369
+	{
370
+		$this->oauthClientService->revokeAccessToken(\Auth::user()->token());
371
+	}
372
+
373
+	/**
374
+	 * Attempt to refresh the access token using the given refresh token.
375
+	 *
376
+	 * @param  string $refreshToken
377
+	 * @return array
378
+	 */
379
+	public function refreshToken($refreshToken)
380
+	{
381
+		return $this->loginProxy->refreshToken($refreshToken);
382
+	}
383 383
 }
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->detachPermissions($userId);
136 136
             $this->repo->attachPermissions($userId, $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('skeleton.disable_confirm_email') && ! $user->confirmed) {
155
+        } elseif ( ! config('skeleton.disable_confirm_email') && ! $user->confirmed) {
156 156
             \Errors::emailNotConfirmed();
157 157
         }
158 158
 
@@ -171,11 +171,11 @@  discard block
 block discarded – undo
171 171
         $access_token = $authCode ? Arr::get(\Socialite::driver($type)->getAccessTokenResponse($authCode), 'access_token') : $accessToken;
172 172
         $user         = \Socialite::driver($type)->userFromToken($access_token);
173 173
 
174
-        if (! $user->email) {
174
+        if ( ! $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->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('skeleton.disable_confirm_email')) {
203
+        if ( ! $skipConfirmEmail && ! config('skeleton.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/Database/Seeds/UsersTableSeeder.php 2 patches
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 = 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.
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'       => '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.
src/Modules/Users/Database/Seeds/AssignRelationsSeeder.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 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.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
         /**
19 19
          * Assign the permissions to the admin role.
20 20
          */
21
-        \DB::table('permissions')->orderBy('created_at', 'asc')->whereIn('model', ['user'])->each(function ($permission) use ($adminRoleId) {
21
+        \DB::table('permissions')->orderBy('created_at', 'asc')->whereIn('model', ['user'])->each(function($permission) use ($adminRoleId) {
22 22
             \DB::table('permission_role')->insert(
23 23
                 [
24 24
                 'permission_id' => $permission->id,
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.
PushNotificationDevices/Repositories/PushNotificationDeviceRepository.php 2 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -8,14 +8,14 @@
 block discarded – undo
8 8
 
9 9
 class PushNotificationDeviceRepository extends BaseRepository
10 10
 {
11
-    /**
12
-     * Init new object.
13
-     *
14
-     * @param   PushNotificationDevice $model
15
-     * @return  void
16
-     */
17
-    public function __construct(PushNotificationDevice $model)
18
-    {
19
-        parent::__construct($model);
20
-    }
11
+	/**
12
+	 * Init new object.
13
+	 *
14
+	 * @param   PushNotificationDevice $model
15
+	 * @return  void
16
+	 */
17
+	public function __construct(PushNotificationDevice $model)
18
+	{
19
+		parent::__construct($model);
20
+	}
21 21
 }
Please login to merge, or discard this patch.
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\Repositories;
4 4
 
5 5
 use App\Modules\Core\BaseClasses\BaseRepository;
6
-use LaravelFCM\Message\OptionsBuilder;
7
-use LaravelFCM\Message\PayloadDataBuilder;
8
-use LaravelFCM\Message\PayloadNotificationBuilder;
9 6
 use App\Modules\PushNotificationDevices\PushNotificationDevice;
10 7
 
11 8
 class PushNotificationDeviceRepository extends BaseRepository
Please login to merge, or discard this patch.
Modules/PushNotificationDevices/Database/Seeds/AssignRelationsSeeder.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 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', ['pushNotificationDevice'])->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', ['pushNotificationDevice'])->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.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
         /**
19 19
          * Assign the permissions to the admin role.
20 20
          */
21
-        \DB::table('permissions')->orderBy('created_at', 'asc')->whereIn('model', ['pushNotificationDevice'])->each(function ($permission) use ($adminRoleId) {
21
+        \DB::table('permissions')->orderBy('created_at', 'asc')->whereIn('model', ['pushNotificationDevice'])->each(function($permission) use ($adminRoleId) {
22 22
             \DB::table('permission_role')->insert(
23 23
                 [
24 24
                 'permission_id' => $permission->id,
Please login to merge, or discard this patch.