Completed
Push — master ( 2c4876...f9862b )
by Sherif
10:06
created
src/Modules/V1/Reporting/Report.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -5,32 +5,32 @@
 block discarded – undo
5 5
 
6 6
 class Report extends Model{
7 7
 
8
-    use SoftDeletes;
8
+	use SoftDeletes;
9 9
 	protected $table    = 'reports';
10 10
 	protected $dates    = ['created_at', 'updated_at', 'deleted_at'];
11 11
 	protected $hidden   = ['deleted_at'];
12 12
 	protected $guarded  = ['id'];
13 13
 	protected $fillable = ['report_name', 'view_name'];
14
-    public $searchable  = ['report_name', 'view_name'];
14
+	public $searchable  = ['report_name', 'view_name'];
15 15
 
16 16
 	public function getCreatedAtAttribute($value)
17
-    {
18
-        return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
19
-    }
17
+	{
18
+		return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
19
+	}
20 20
 
21
-    public function getUpdatedAtAttribute($value)
22
-    {
23
-        return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
24
-    }
21
+	public function getUpdatedAtAttribute($value)
22
+	{
23
+		return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
24
+	}
25 25
 
26
-    public function getDeletedAtAttribute($value)
27
-    {
28
-        return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
29
-    }
26
+	public function getDeletedAtAttribute($value)
27
+	{
28
+		return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
29
+	}
30 30
     
31
-    public static function boot()
32
-    {
33
-        parent::boot();
34
-        parent::observe(\App::make('App\Modules\V1\Reporting\ModelObservers\ReprotObserver'));
35
-    }
31
+	public static function boot()
32
+	{
33
+		parent::boot();
34
+		parent::observe(\App::make('App\Modules\V1\Reporting\ModelObservers\ReprotObserver'));
35
+	}
36 36
 }
Please login to merge, or discard this patch.
src/Modules/V1/Notifications/Notification.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -5,23 +5,23 @@
 block discarded – undo
5 5
 
6 6
 class Notification extends DatabaseNotification{
7 7
 
8
-    public function getCreatedAtAttribute($value)
9
-    {
10
-        return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
11
-    }
8
+	public function getCreatedAtAttribute($value)
9
+	{
10
+		return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
11
+	}
12 12
 
13
-    public function getUpdatedAtAttribute($value)
14
-    {
15
-        return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
16
-    }
13
+	public function getUpdatedAtAttribute($value)
14
+	{
15
+		return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
16
+	}
17 17
 
18
-    public function getDeletedAtAttribute($value)
19
-    {
20
-        return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
21
-    }
18
+	public function getDeletedAtAttribute($value)
19
+	{
20
+		return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
21
+	}
22 22
 
23
-    public function getReadAtAttribute($value)
24
-    {
25
-        return ! $value ? false : \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
26
-    }
23
+	public function getReadAtAttribute($value)
24
+	{
25
+		return ! $value ? false : \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
26
+	}
27 27
 }
Please login to merge, or discard this patch.
src/Modules/V1/Notifications/PushNotificationDevice.php 1 patch
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -5,48 +5,48 @@
 block discarded – undo
5 5
 
6 6
 class PushNotificationDevice extends Model{
7 7
 
8
-    use SoftDeletes;
9
-    protected $table    = 'push_notifications_devices';
10
-    protected $dates    = ['created_at', 'updated_at', 'deleted_at'];
11
-    protected $hidden   = ['deleted_at', 'access_token'];
12
-    protected $guarded  = ['id'];
13
-    protected $fillable = ['device_token', 'user_id', 'access_token'];
14
-    public $searchable  = ['device_token'];
15
-
16
-    public function getCreatedAtAttribute($value)
17
-    {
18
-        return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
19
-    }
20
-
21
-    public function getUpdatedAtAttribute($value)
22
-    {
23
-        return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
24
-    }
25
-
26
-    public function getDeletedAtAttribute($value)
27
-    {
28
-        return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
29
-    }
8
+	use SoftDeletes;
9
+	protected $table    = 'push_notifications_devices';
10
+	protected $dates    = ['created_at', 'updated_at', 'deleted_at'];
11
+	protected $hidden   = ['deleted_at', 'access_token'];
12
+	protected $guarded  = ['id'];
13
+	protected $fillable = ['device_token', 'user_id', 'access_token'];
14
+	public $searchable  = ['device_token'];
15
+
16
+	public function getCreatedAtAttribute($value)
17
+	{
18
+		return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
19
+	}
20
+
21
+	public function getUpdatedAtAttribute($value)
22
+	{
23
+		return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
24
+	}
25
+
26
+	public function getDeletedAtAttribute($value)
27
+	{
28
+		return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
29
+	}
30 30
     
31
-    public function user()
32
-    {
33
-        return $this->belongsTo('App\Modules\V1\Acl\AclUser');
34
-    }
35
-
36
-    /**
37
-     * Encrypt the access_token attribute before
38
-     * saving it in the storage.
39
-     * 
40
-     * @param string $value 
41
-     */
42
-    public function setLoginTokenAttribute($value)
43
-    {
44
-        $this->attributes['access_token'] = encrypt($value);
45
-    }
46
-
47
-    public static function boot()
48
-    {
49
-        parent::boot();
50
-        parent::observe(\App::make('App\Modules\V1\Notifications\ModelObservers\PushNotificationDeviceObserver'));
51
-    }
31
+	public function user()
32
+	{
33
+		return $this->belongsTo('App\Modules\V1\Acl\AclUser');
34
+	}
35
+
36
+	/**
37
+	 * Encrypt the access_token attribute before
38
+	 * saving it in the storage.
39
+	 * 
40
+	 * @param string $value 
41
+	 */
42
+	public function setLoginTokenAttribute($value)
43
+	{
44
+		$this->attributes['access_token'] = encrypt($value);
45
+	}
46
+
47
+	public static function boot()
48
+	{
49
+		parent::boot();
50
+		parent::observe(\App::make('App\Modules\V1\Notifications\ModelObservers\PushNotificationDeviceObserver'));
51
+	}
52 52
 }
Please login to merge, or discard this patch.
src/Modules/V1/Acl/OauthClient.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -6,23 +6,23 @@
 block discarded – undo
6 6
 
7 7
 class OauthClient extends Client
8 8
 {
9
-    protected $dates    = ['created_at', 'updated_at'];
10
-    protected $fillable = ['name', 'redirect', 'user_id', 'personal_access_client', 'password_client', 'revoked'];
11
-    public $searchable  = ['name'];
9
+	protected $dates    = ['created_at', 'updated_at'];
10
+	protected $fillable = ['name', 'redirect', 'user_id', 'personal_access_client', 'password_client', 'revoked'];
11
+	public $searchable  = ['name'];
12 12
     
13
-    public function getCreatedAtAttribute($value)
14
-    {
15
-        return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
16
-    }
13
+	public function getCreatedAtAttribute($value)
14
+	{
15
+		return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
16
+	}
17 17
 
18
-    public function getUpdatedAtAttribute($value)
19
-    {
20
-        return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
21
-    }
18
+	public function getUpdatedAtAttribute($value)
19
+	{
20
+		return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
21
+	}
22 22
     
23
-    public static function boot()
24
-    {
25
-        parent::boot();
26
-        parent::observe(\App::make('App\Modules\V1\Acl\ModelObservers\OauthClientObserver'));
27
-    }
23
+	public static function boot()
24
+	{
25
+		parent::boot();
26
+		parent::observe(\App::make('App\Modules\V1\Acl\ModelObservers\OauthClientObserver'));
27
+	}
28 28
 }
Please login to merge, or discard this patch.
src/Modules/V1/Acl/AclUser.php 1 patch
Indentation   +113 added lines, -113 removed lines patch added patch discarded remove patch
@@ -7,119 +7,119 @@
 block discarded – undo
7 7
 
8 8
 class AclUser extends User {
9 9
 
10
-    use SoftDeletes, HasApiTokens;
11
-    protected $table    = 'users';
12
-    protected $dates    = ['created_at', 'updated_at', 'deleted_at'];
13
-    protected $hidden   = ['password', 'remember_token','deleted_at', 'two_factor_code'];
14
-    protected $guarded  = ['id'];
15
-    protected $fillable = ['profile_picture', 'name', 'email', 'password'];
16
-    public $searchable  = ['name', 'email'];
10
+	use SoftDeletes, HasApiTokens;
11
+	protected $table    = 'users';
12
+	protected $dates    = ['created_at', 'updated_at', 'deleted_at'];
13
+	protected $hidden   = ['password', 'remember_token','deleted_at', 'two_factor_code'];
14
+	protected $guarded  = ['id'];
15
+	protected $fillable = ['profile_picture', 'name', 'email', 'password'];
16
+	public $searchable  = ['name', 'email'];
17 17
     
18
-    public function getCreatedAtAttribute($value)
19
-    {
20
-        return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
21
-    }
22
-
23
-    public function getUpdatedAtAttribute($value)
24
-    {
25
-        return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
26
-    }
27
-
28
-    public function getDeletedAtAttribute($value)
29
-    {
30
-        return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
31
-    }
32
-
33
-    /**
34
-     * Encrypt the password attribute before
35
-     * saving it in the storage.
36
-     * 
37
-     * @param string $value 
38
-     */
39
-    public function setPasswordAttribute($value)
40
-    {
41
-        $this->attributes['password'] = bcrypt($value);
42
-    }
43
-
44
-    /**
45
-     * Get the entity's notifications.
46
-     */
47
-    public function notifications()
48
-    {
49
-        return $this->morphMany('\App\Modules\V1\Notifications\Notification', 'notifiable')->orderBy('created_at', 'desc');
50
-    }
51
-
52
-    /**
53
-     * Get the entity's read notifications.
54
-     */
55
-    public function readNotifications()
56
-    {
57
-        return $this->notifications()->whereNotNull('read_at');
58
-    }
59
-
60
-    /**
61
-     * Get the entity's unread notifications.
62
-     */
63
-    public function unreadNotifications()
64
-    {
65
-        return $this->notifications()->whereNull('read_at');
66
-    }
67
-
68
-    public function groups()
69
-    {
70
-        return $this->belongsToMany('\App\Modules\V1\Acl\AclGroup','users_groups','user_id','group_id')->whereNull('users_groups.deleted_at')->withTimestamps();
71
-    }
72
-
73
-    public function oauthClients()
74
-    {
75
-        return $this->hasMany('App\Modules\V1\Acl\OauthClient', 'user_id');
76
-    }
77
-
78
-    /**
79
-     * Return fcm device tokens that will be used in sending fcm notifications.
80
-     * 
81
-     * @return array
82
-     */
83
-    public function routeNotificationForFCM()
84
-    {
85
-        $devices = \Core::pushNotificationsDevices()->findBy(['user_id' => $this->id]);
86
-        $tokens  = [];
87
-
88
-        foreach ($devices as $device) 
89
-        {
90
-            $accessToken = decrypt($device->access_token);
91
-
92
-            try
93
-            {
94
-                if (\Core::users()->accessTokenExpiredOrRevoked($accessToken)) 
95
-                {
96
-                    continue;
97
-                }
98
-
99
-                $tokens[] = $device->device_token;
100
-            } 
101
-            catch (\Exception $e) 
102
-            {
103
-                $device->forceDelete();
104
-            }
105
-        }
106
-
107
-        return $tokens;
108
-    }
109
-
110
-    /**
111
-     * The channels the user receives notification broadcasts on.
112
-     *
113
-     * @return string
114
-     */
115
-    public function receivesBroadcastNotificationsOn()
116
-    {
117
-        return 'users.' . $this->id;
118
-    }
18
+	public function getCreatedAtAttribute($value)
19
+	{
20
+		return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
21
+	}
22
+
23
+	public function getUpdatedAtAttribute($value)
24
+	{
25
+		return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
26
+	}
27
+
28
+	public function getDeletedAtAttribute($value)
29
+	{
30
+		return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
31
+	}
32
+
33
+	/**
34
+	 * Encrypt the password attribute before
35
+	 * saving it in the storage.
36
+	 * 
37
+	 * @param string $value 
38
+	 */
39
+	public function setPasswordAttribute($value)
40
+	{
41
+		$this->attributes['password'] = bcrypt($value);
42
+	}
43
+
44
+	/**
45
+	 * Get the entity's notifications.
46
+	 */
47
+	public function notifications()
48
+	{
49
+		return $this->morphMany('\App\Modules\V1\Notifications\Notification', 'notifiable')->orderBy('created_at', 'desc');
50
+	}
51
+
52
+	/**
53
+	 * Get the entity's read notifications.
54
+	 */
55
+	public function readNotifications()
56
+	{
57
+		return $this->notifications()->whereNotNull('read_at');
58
+	}
59
+
60
+	/**
61
+	 * Get the entity's unread notifications.
62
+	 */
63
+	public function unreadNotifications()
64
+	{
65
+		return $this->notifications()->whereNull('read_at');
66
+	}
67
+
68
+	public function groups()
69
+	{
70
+		return $this->belongsToMany('\App\Modules\V1\Acl\AclGroup','users_groups','user_id','group_id')->whereNull('users_groups.deleted_at')->withTimestamps();
71
+	}
72
+
73
+	public function oauthClients()
74
+	{
75
+		return $this->hasMany('App\Modules\V1\Acl\OauthClient', 'user_id');
76
+	}
77
+
78
+	/**
79
+	 * Return fcm device tokens that will be used in sending fcm notifications.
80
+	 * 
81
+	 * @return array
82
+	 */
83
+	public function routeNotificationForFCM()
84
+	{
85
+		$devices = \Core::pushNotificationsDevices()->findBy(['user_id' => $this->id]);
86
+		$tokens  = [];
87
+
88
+		foreach ($devices as $device) 
89
+		{
90
+			$accessToken = decrypt($device->access_token);
91
+
92
+			try
93
+			{
94
+				if (\Core::users()->accessTokenExpiredOrRevoked($accessToken)) 
95
+				{
96
+					continue;
97
+				}
98
+
99
+				$tokens[] = $device->device_token;
100
+			} 
101
+			catch (\Exception $e) 
102
+			{
103
+				$device->forceDelete();
104
+			}
105
+		}
106
+
107
+		return $tokens;
108
+	}
109
+
110
+	/**
111
+	 * The channels the user receives notification broadcasts on.
112
+	 *
113
+	 * @return string
114
+	 */
115
+	public function receivesBroadcastNotificationsOn()
116
+	{
117
+		return 'users.' . $this->id;
118
+	}
119 119
     
120
-    public static function boot()
121
-    {
122
-        parent::boot();
123
-        parent::observe(\App::make('App\Modules\V1\Acl\ModelObservers\AclUserObserver'));
124
-    }
120
+	public static function boot()
121
+	{
122
+		parent::boot();
123
+		parent::observe(\App::make('App\Modules\V1\Acl\ModelObservers\AclUserObserver'));
124
+	}
125 125
 }
Please login to merge, or discard this patch.
src/Modules/V1/Acl/AclGroup.php 1 patch
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -5,42 +5,42 @@
 block discarded – undo
5 5
 
6 6
 class AclGroup extends Model{
7 7
 
8
-    use SoftDeletes;
9
-    protected $table    = 'groups';
10
-    protected $dates    = ['created_at', 'updated_at', 'deleted_at'];
11
-    protected $hidden   = ['deleted_at'];
12
-    protected $guarded  = ['id'];
13
-    protected $fillable = ['name'];
14
-    public $searchable  = ['name'];
15
-
16
-    public function getCreatedAtAttribute($value)
17
-    {
18
-        return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
19
-    }
20
-
21
-    public function getUpdatedAtAttribute($value)
22
-    {
23
-        return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
24
-    }
25
-
26
-    public function getDeletedAtAttribute($value)
27
-    {
28
-        return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
29
-    }
30
-
31
-    public function users()
32
-    {
33
-        return $this->belongsToMany('\App\Modules\V1\Acl\AclUser','users_groups','group_id','user_id')->whereNull('users_groups.deleted_at')->withTimestamps();
34
-    }
35
-
36
-    public function permissions()
37
-    {
38
-        return $this->belongsToMany('\App\Modules\V1\Acl\AclPermission','groups_permissions','group_id','permission_id')->whereNull('groups_permissions.deleted_at')->withTimestamps();
39
-    }
40
-
41
-    public static function boot()
42
-    {
43
-        parent::boot();
44
-        parent::observe(\App::make('App\Modules\V1\Acl\ModelObservers\AclGroupObserver'));
45
-    }
8
+	use SoftDeletes;
9
+	protected $table    = 'groups';
10
+	protected $dates    = ['created_at', 'updated_at', 'deleted_at'];
11
+	protected $hidden   = ['deleted_at'];
12
+	protected $guarded  = ['id'];
13
+	protected $fillable = ['name'];
14
+	public $searchable  = ['name'];
15
+
16
+	public function getCreatedAtAttribute($value)
17
+	{
18
+		return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
19
+	}
20
+
21
+	public function getUpdatedAtAttribute($value)
22
+	{
23
+		return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
24
+	}
25
+
26
+	public function getDeletedAtAttribute($value)
27
+	{
28
+		return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
29
+	}
30
+
31
+	public function users()
32
+	{
33
+		return $this->belongsToMany('\App\Modules\V1\Acl\AclUser','users_groups','group_id','user_id')->whereNull('users_groups.deleted_at')->withTimestamps();
34
+	}
35
+
36
+	public function permissions()
37
+	{
38
+		return $this->belongsToMany('\App\Modules\V1\Acl\AclPermission','groups_permissions','group_id','permission_id')->whereNull('groups_permissions.deleted_at')->withTimestamps();
39
+	}
40
+
41
+	public static function boot()
42
+	{
43
+		parent::boot();
44
+		parent::observe(\App::make('App\Modules\V1\Acl\ModelObservers\AclGroupObserver'));
45
+	}
46 46
 }
Please login to merge, or discard this patch.
src/Modules/V1/Acl/Database/Factories/UserFactory.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 $factory->define(App\Modules\V1\Acl\AclUser::class, function (Faker\Generator $faker) {
4
-    return [
4
+	return [
5 5
 		'profile_picture' => 'http://lorempixel.com/400/200/',
6 6
 		'name'            => $faker->name(),
7 7
 		'email'           => $faker->safeEmail(),
8 8
 		'password'        => 123456,
9 9
 		'created_at'      => $faker->dateTimeBetween('-1 years', 'now'),
10 10
 		'updated_at'      => $faker->dateTimeBetween('-1 years', 'now')
11
-    ];
11
+	];
12 12
 });
Please login to merge, or discard this patch.
src/Modules/V1/Acl/Repositories/UserRepository.php 1 patch
Indentation   +382 added lines, -382 removed lines patch added patch discarded remove patch
@@ -5,394 +5,394 @@
 block discarded – undo
5 5
 
6 6
 class UserRepository extends AbstractRepository
7 7
 {
8
-    /**
9
-     * Return the model full namespace.
10
-     * 
11
-     * @return string
12
-     */
13
-    protected function getModel()
14
-    {
15
-        return 'App\Modules\V1\Acl\AclUser';
16
-    }
17
-
18
-
19
-    /**
20
-     * Return the logged in user account.
21
-     *
22
-     * @param  array   $relations
23
-     * @return boolean
24
-     */
25
-    public function account($relations = [])
26
-    {
27
-        $permissions = [];
28
-        $user        = \Core::users()->find(\Auth::id(), $relations);
29
-        foreach ($user->groups()->get() as $group)
30
-        {
31
-            $group->permissions->each(function ($permission) use (&$permissions){
32
-                $permissions[$permission->model][$permission->id] = $permission->name;
33
-            });
34
-        }
35
-        $user->permissions = $permissions;
36
-
37
-       return $user;
38
-    }
39
-
40
-    /**
41
-     * Check if the logged in user or the given user 
42
-     * has the given permissions on the given model.
43
-     * 
44
-     * @param  string  $nameOfPermission
45
-     * @param  string  $model            
46
-     * @param  boolean $user
47
-     * @return boolean
48
-     */
49
-    public function can($nameOfPermission, $model, $user = false)
50
-    {      
51
-        $user        = $user ?: $this->find(\Auth::id(), ['groups.permissions']);
52
-        $permissions = [];
53
-
54
-        $user->groups->pluck('permissions')->each(function ($permission) use (&$permissions, $model){
55
-            $permissions = array_merge($permissions, $permission->where('model', $model)->pluck('name')->toArray()); 
56
-        });
8
+	/**
9
+	 * Return the model full namespace.
10
+	 * 
11
+	 * @return string
12
+	 */
13
+	protected function getModel()
14
+	{
15
+		return 'App\Modules\V1\Acl\AclUser';
16
+	}
17
+
18
+
19
+	/**
20
+	 * Return the logged in user account.
21
+	 *
22
+	 * @param  array   $relations
23
+	 * @return boolean
24
+	 */
25
+	public function account($relations = [])
26
+	{
27
+		$permissions = [];
28
+		$user        = \Core::users()->find(\Auth::id(), $relations);
29
+		foreach ($user->groups()->get() as $group)
30
+		{
31
+			$group->permissions->each(function ($permission) use (&$permissions){
32
+				$permissions[$permission->model][$permission->id] = $permission->name;
33
+			});
34
+		}
35
+		$user->permissions = $permissions;
36
+
37
+	   return $user;
38
+	}
39
+
40
+	/**
41
+	 * Check if the logged in user or the given user 
42
+	 * has the given permissions on the given model.
43
+	 * 
44
+	 * @param  string  $nameOfPermission
45
+	 * @param  string  $model            
46
+	 * @param  boolean $user
47
+	 * @return boolean
48
+	 */
49
+	public function can($nameOfPermission, $model, $user = false)
50
+	{      
51
+		$user        = $user ?: $this->find(\Auth::id(), ['groups.permissions']);
52
+		$permissions = [];
53
+
54
+		$user->groups->pluck('permissions')->each(function ($permission) use (&$permissions, $model){
55
+			$permissions = array_merge($permissions, $permission->where('model', $model)->pluck('name')->toArray()); 
56
+		});
57 57
         
58
-        return in_array($nameOfPermission, $permissions);
59
-    }
60
-
61
-    /**
62
-     * Check if the logged in user has the given group.
63
-     * 
64
-     * @param  string  $groupName
65
-     * @param  integer $userId
66
-     * @return boolean
67
-     */
68
-    public function hasGroup($groups, $user = false)
69
-    {
70
-        $user = $user ?: $this->find(\Auth::id());
71
-        return $user->groups->whereIn('name', $groups)->count() ? true : false;
72
-    }
73
-
74
-    /**
75
-     * Assign the given group ids to the given user.
76
-     * 
77
-     * @param  integer $user_id    
78
-     * @param  array   $group_ids
79
-     * @return object
80
-     */
81
-    public function assignGroups($user_id, $group_ids)
82
-    {
83
-        \DB::transaction(function () use ($user_id, $group_ids) {
84
-            $user = $this->find($user_id);
85
-            $user->groups()->detach();
86
-            $user->groups()->attach($group_ids);
87
-        });
88
-
89
-        return $this->find($user_id);
90
-    }
91
-
92
-
93
-    /**
94
-     * Handle a login request to the application.
95
-     * 
96
-     * @param  array   $credentials    
97
-     * @param  boolean $adminLogin
98
-     * @return object
99
-     */
100
-    public function login($credentials, $adminLogin = false)
101
-    {
102
-        if ( ! $user = $this->first(['email' => $credentials['email']])) 
103
-        {
104
-            \ErrorHandler::loginFailed();
105
-        }
106
-        else if ($adminLogin && ! $user->groups->whereIn('name', ['Admin'])->count()) 
107
-        {
108
-            \ErrorHandler::loginFailed();
109
-        }
110
-        else if ( ! $adminLogin && $user->groups->whereIn('name', ['Admin'])->count()) 
111
-        {
112
-            \ErrorHandler::loginFailed();
113
-        }
114
-        else if ($user->blocked)
115
-        {
116
-            \ErrorHandler::userIsBlocked();
117
-        }
118
-        else if ( ! $user->confirmed)
119
-        {
120
-            \ErrorHandler::emailNotConfirmed();
121
-        }
122
-
123
-        return $user;
124
-    }
125
-
126
-    /**
127
-     * Handle a social login request of the none admin to the application.
128
-     * 
129
-     * @param  array   $credentials
130
-     * @return array
131
-     */
132
-    public function loginSocial($credentials)
133
-    {
134
-        $access_token = $credentials['auth_code'] ? \Socialite::driver($credentials['type'])->getAccessToken($credentials['auth_code']) : $credentials['access_token'];
135
-        $user         = \Socialite::driver($credentials['type'])->userFromToken($access_token);
136
-
137
-        if ( ! $user->email)
138
-        {
139
-            \ErrorHandler::noSocialEmail();
140
-        }
141
-
142
-        if ( ! $registeredUser = $this->model->where('email', $user->email)->first()) 
143
-        {
144
-            $data = ['email' => $user->email, 'password' => ''];
145
-            return $this->register($data);
146
-        }
147
-        else
148
-        {
149
-            if ( ! \Auth::attempt(['email' => $registeredUser->email, 'password' => '']))
150
-            {
151
-                \ErrorHandler::userAlreadyRegistered();
152
-            }
153
-
154
-            $loginProxy = \App::make('App\Modules\V1\Acl\Proxy\LoginProxy');
155
-            return $loginProxy->login(['email' => $registeredUser->email, 'password' => ''], 0);
156
-        }
157
-    }
58
+		return in_array($nameOfPermission, $permissions);
59
+	}
60
+
61
+	/**
62
+	 * Check if the logged in user has the given group.
63
+	 * 
64
+	 * @param  string  $groupName
65
+	 * @param  integer $userId
66
+	 * @return boolean
67
+	 */
68
+	public function hasGroup($groups, $user = false)
69
+	{
70
+		$user = $user ?: $this->find(\Auth::id());
71
+		return $user->groups->whereIn('name', $groups)->count() ? true : false;
72
+	}
73
+
74
+	/**
75
+	 * Assign the given group ids to the given user.
76
+	 * 
77
+	 * @param  integer $user_id    
78
+	 * @param  array   $group_ids
79
+	 * @return object
80
+	 */
81
+	public function assignGroups($user_id, $group_ids)
82
+	{
83
+		\DB::transaction(function () use ($user_id, $group_ids) {
84
+			$user = $this->find($user_id);
85
+			$user->groups()->detach();
86
+			$user->groups()->attach($group_ids);
87
+		});
88
+
89
+		return $this->find($user_id);
90
+	}
91
+
92
+
93
+	/**
94
+	 * Handle a login request to the application.
95
+	 * 
96
+	 * @param  array   $credentials    
97
+	 * @param  boolean $adminLogin
98
+	 * @return object
99
+	 */
100
+	public function login($credentials, $adminLogin = false)
101
+	{
102
+		if ( ! $user = $this->first(['email' => $credentials['email']])) 
103
+		{
104
+			\ErrorHandler::loginFailed();
105
+		}
106
+		else if ($adminLogin && ! $user->groups->whereIn('name', ['Admin'])->count()) 
107
+		{
108
+			\ErrorHandler::loginFailed();
109
+		}
110
+		else if ( ! $adminLogin && $user->groups->whereIn('name', ['Admin'])->count()) 
111
+		{
112
+			\ErrorHandler::loginFailed();
113
+		}
114
+		else if ($user->blocked)
115
+		{
116
+			\ErrorHandler::userIsBlocked();
117
+		}
118
+		else if ( ! $user->confirmed)
119
+		{
120
+			\ErrorHandler::emailNotConfirmed();
121
+		}
122
+
123
+		return $user;
124
+	}
125
+
126
+	/**
127
+	 * Handle a social login request of the none admin to the application.
128
+	 * 
129
+	 * @param  array   $credentials
130
+	 * @return array
131
+	 */
132
+	public function loginSocial($credentials)
133
+	{
134
+		$access_token = $credentials['auth_code'] ? \Socialite::driver($credentials['type'])->getAccessToken($credentials['auth_code']) : $credentials['access_token'];
135
+		$user         = \Socialite::driver($credentials['type'])->userFromToken($access_token);
136
+
137
+		if ( ! $user->email)
138
+		{
139
+			\ErrorHandler::noSocialEmail();
140
+		}
141
+
142
+		if ( ! $registeredUser = $this->model->where('email', $user->email)->first()) 
143
+		{
144
+			$data = ['email' => $user->email, 'password' => ''];
145
+			return $this->register($data);
146
+		}
147
+		else
148
+		{
149
+			if ( ! \Auth::attempt(['email' => $registeredUser->email, 'password' => '']))
150
+			{
151
+				\ErrorHandler::userAlreadyRegistered();
152
+			}
153
+
154
+			$loginProxy = \App::make('App\Modules\V1\Acl\Proxy\LoginProxy');
155
+			return $loginProxy->login(['email' => $registeredUser->email, 'password' => ''], 0);
156
+		}
157
+	}
158 158
     
159
-    /**
160
-     * Handle a registration request.
161
-     * 
162
-     * @param  array $credentials
163
-     * @return array
164
-     */
165
-    public function register($credentials)
166
-    {
167
-        $user = $this->save($credentials);
168
-
169
-        if ( ! env('DISABLE_CONFIRM_EMAIL')) 
170
-        {
171
-            $this->sendConfirmationEmail($user->email);
172
-        }
173
-    }
159
+	/**
160
+	 * Handle a registration request.
161
+	 * 
162
+	 * @param  array $credentials
163
+	 * @return array
164
+	 */
165
+	public function register($credentials)
166
+	{
167
+		$user = $this->save($credentials);
168
+
169
+		if ( ! env('DISABLE_CONFIRM_EMAIL')) 
170
+		{
171
+			$this->sendConfirmationEmail($user->email);
172
+		}
173
+	}
174 174
     
175
-    /**
176
-     * Block the user.
177
-     *
178
-     * @param  integer $user_id
179
-     * @return object
180
-     */
181
-    public function block($user_id)
182
-    {
183
-        if ( ! $user = $this->find($user_id)) 
184
-        {
185
-            \ErrorHandler::notFound('user');
186
-        }
187
-        if ( ! $this->hasGroup(['Admin']))
188
-        {
189
-            \ErrorHandler::noPermissions();
190
-        }
191
-        else if (\Auth::id() == $user_id)
192
-        {
193
-            \ErrorHandler::noPermissions();
194
-        }
195
-        else if ($user->groups->pluck('name')->search('Admin', true) !== false) 
196
-        {
197
-            \ErrorHandler::noPermissions();
198
-        }
199
-
200
-        $user->blocked = 1;
201
-        $user->save();
175
+	/**
176
+	 * Block the user.
177
+	 *
178
+	 * @param  integer $user_id
179
+	 * @return object
180
+	 */
181
+	public function block($user_id)
182
+	{
183
+		if ( ! $user = $this->find($user_id)) 
184
+		{
185
+			\ErrorHandler::notFound('user');
186
+		}
187
+		if ( ! $this->hasGroup(['Admin']))
188
+		{
189
+			\ErrorHandler::noPermissions();
190
+		}
191
+		else if (\Auth::id() == $user_id)
192
+		{
193
+			\ErrorHandler::noPermissions();
194
+		}
195
+		else if ($user->groups->pluck('name')->search('Admin', true) !== false) 
196
+		{
197
+			\ErrorHandler::noPermissions();
198
+		}
199
+
200
+		$user->blocked = 1;
201
+		$user->save();
202 202
         
203
-        return $user;
204
-    }
205
-
206
-    /**
207
-     * Unblock the user.
208
-     *
209
-     * @param  integer $user_id
210
-     * @return object
211
-     */
212
-    public function unblock($user_id)
213
-    {
214
-        if ( ! $this->hasGroup(['Admin']))
215
-        {
216
-            \ErrorHandler::noPermissions();
217
-        }
218
-
219
-        $user          = $this->find($user_id);
220
-        $user->blocked = 0;
221
-        $user->save();
222
-
223
-        return $user;
224
-    }
225
-
226
-    /**
227
-     * Send a reset link to the given user.
228
-     *
229
-     * @param  string  $email
230
-     * @return void
231
-     */
232
-    public function sendReset($email)
233
-    {
234
-        if ( ! $user = $this->model->where('email', $email)->first())
235
-        {
236
-            \ErrorHandler::notFound('email');
237
-        }
238
-
239
-        $token = \Password::getRepository()->create($user);
240
-        \Core::notifications()->notify($user, 'ResetPassword', $token);
241
-    }
242
-
243
-    /**
244
-     * Reset the given user's password.
245
-     *
246
-     * @param  array  $credentials
247
-     * @return array
248
-     */
249
-    public function resetPassword($credentials)
250
-    {
251
-        $response = \Password::reset($credentials, function ($user, $password) {
252
-            $user->password = $password;
253
-            $user->save();
254
-        });
255
-
256
-        switch ($response) {
257
-            case \Password::PASSWORD_RESET:
258
-                return 'success';
203
+		return $user;
204
+	}
205
+
206
+	/**
207
+	 * Unblock the user.
208
+	 *
209
+	 * @param  integer $user_id
210
+	 * @return object
211
+	 */
212
+	public function unblock($user_id)
213
+	{
214
+		if ( ! $this->hasGroup(['Admin']))
215
+		{
216
+			\ErrorHandler::noPermissions();
217
+		}
218
+
219
+		$user          = $this->find($user_id);
220
+		$user->blocked = 0;
221
+		$user->save();
222
+
223
+		return $user;
224
+	}
225
+
226
+	/**
227
+	 * Send a reset link to the given user.
228
+	 *
229
+	 * @param  string  $email
230
+	 * @return void
231
+	 */
232
+	public function sendReset($email)
233
+	{
234
+		if ( ! $user = $this->model->where('email', $email)->first())
235
+		{
236
+			\ErrorHandler::notFound('email');
237
+		}
238
+
239
+		$token = \Password::getRepository()->create($user);
240
+		\Core::notifications()->notify($user, 'ResetPassword', $token);
241
+	}
242
+
243
+	/**
244
+	 * Reset the given user's password.
245
+	 *
246
+	 * @param  array  $credentials
247
+	 * @return array
248
+	 */
249
+	public function resetPassword($credentials)
250
+	{
251
+		$response = \Password::reset($credentials, function ($user, $password) {
252
+			$user->password = $password;
253
+			$user->save();
254
+		});
255
+
256
+		switch ($response) {
257
+			case \Password::PASSWORD_RESET:
258
+				return 'success';
259 259
                 
260
-            case \Password::INVALID_TOKEN:
261
-                \ErrorHandler::invalidResetToken('token');
262
-
263
-            case \Password::INVALID_PASSWORD:
264
-                \ErrorHandler::invalidResetPassword('email');
265
-
266
-            case \Password::INVALID_USER:
267
-                \ErrorHandler::notFound('user');
268
-
269
-            default:
270
-                \ErrorHandler::generalError();
271
-        }
272
-    }
273
-
274
-    /**
275
-     * Change the logged in user password.
276
-     *
277
-     * @param  array  $credentials
278
-     * @return void
279
-     */
280
-    public function changePassword($credentials)
281
-    {
282
-        $user = \Auth::user();
283
-        if ( ! \Hash::check($credentials['old_password'], $user->password)) 
284
-        {
285
-            \ErrorHandler::invalidOldPassword();
286
-        }
287
-
288
-        $user->password = $credentials['password'];
289
-        $user->save();
290
-    }
291
-
292
-    /**
293
-     * Confirm email using the confirmation code.
294
-     *
295
-     * @param  string $confirmationCode
296
-     * @return void
297
-     */
298
-    public function confirmEmail($confirmationCode)
299
-    {
300
-        $user                    = $this->first(['confirmation_code' => $confirmationCode]);
301
-        $user->confirmed         = 1;
302
-        $user->confirmation_code = null;
303
-        $user->save();
304
-    }
305
-
306
-    /**
307
-     * Send the confirmation mail.
308
-     *
309
-     * @param  string $email
310
-     * @return void
311
-     */
312
-    public function sendConfirmationEmail($email)
313
-    {
314
-        $user = $this->first(['email' => $email]);
315
-        if ($user->confirmed) 
316
-        {
317
-            \ErrorHandler::emailAlreadyConfirmed();
318
-        }
319
-
320
-        $user->confirmed         = 0;
321
-        $user->confirmation_code = sha1(microtime());
322
-        $user->save();
323
-        \Core::notifications()->notify($user, 'ConfirmEmail');
324
-    }
325
-
326
-    /**
327
-     * Paginate all users in the given group based on the given conditions.
328
-     * 
329
-     * @param  string  $groupName
330
-     * @param  array   $relations
331
-     * @param  integer $perPage
332
-     * @param  string  $sortBy
333
-     * @param  boolean $desc
334
-     * @return \Illuminate\Http\Response
335
-     */
336
-    public function group($conditions, $groupName, $relations, $perPage, $sortBy, $desc)
337
-    {   
338
-        unset($conditions['page']);
339
-        $conditions = $this->constructConditions($conditions, $this->model);
340
-        $sort       = $desc ? 'desc' : 'asc';
341
-        $model      = call_user_func_array("{$this->getModel()}::with", array($relations));
342
-
343
-        $model->whereHas('groups', function($q) use ($groupName){
344
-            $q->where('name', $groupName);
345
-        });
260
+			case \Password::INVALID_TOKEN:
261
+				\ErrorHandler::invalidResetToken('token');
262
+
263
+			case \Password::INVALID_PASSWORD:
264
+				\ErrorHandler::invalidResetPassword('email');
265
+
266
+			case \Password::INVALID_USER:
267
+				\ErrorHandler::notFound('user');
268
+
269
+			default:
270
+				\ErrorHandler::generalError();
271
+		}
272
+	}
273
+
274
+	/**
275
+	 * Change the logged in user password.
276
+	 *
277
+	 * @param  array  $credentials
278
+	 * @return void
279
+	 */
280
+	public function changePassword($credentials)
281
+	{
282
+		$user = \Auth::user();
283
+		if ( ! \Hash::check($credentials['old_password'], $user->password)) 
284
+		{
285
+			\ErrorHandler::invalidOldPassword();
286
+		}
287
+
288
+		$user->password = $credentials['password'];
289
+		$user->save();
290
+	}
291
+
292
+	/**
293
+	 * Confirm email using the confirmation code.
294
+	 *
295
+	 * @param  string $confirmationCode
296
+	 * @return void
297
+	 */
298
+	public function confirmEmail($confirmationCode)
299
+	{
300
+		$user                    = $this->first(['confirmation_code' => $confirmationCode]);
301
+		$user->confirmed         = 1;
302
+		$user->confirmation_code = null;
303
+		$user->save();
304
+	}
305
+
306
+	/**
307
+	 * Send the confirmation mail.
308
+	 *
309
+	 * @param  string $email
310
+	 * @return void
311
+	 */
312
+	public function sendConfirmationEmail($email)
313
+	{
314
+		$user = $this->first(['email' => $email]);
315
+		if ($user->confirmed) 
316
+		{
317
+			\ErrorHandler::emailAlreadyConfirmed();
318
+		}
319
+
320
+		$user->confirmed         = 0;
321
+		$user->confirmation_code = sha1(microtime());
322
+		$user->save();
323
+		\Core::notifications()->notify($user, 'ConfirmEmail');
324
+	}
325
+
326
+	/**
327
+	 * Paginate all users in the given group based on the given conditions.
328
+	 * 
329
+	 * @param  string  $groupName
330
+	 * @param  array   $relations
331
+	 * @param  integer $perPage
332
+	 * @param  string  $sortBy
333
+	 * @param  boolean $desc
334
+	 * @return \Illuminate\Http\Response
335
+	 */
336
+	public function group($conditions, $groupName, $relations, $perPage, $sortBy, $desc)
337
+	{   
338
+		unset($conditions['page']);
339
+		$conditions = $this->constructConditions($conditions, $this->model);
340
+		$sort       = $desc ? 'desc' : 'asc';
341
+		$model      = call_user_func_array("{$this->getModel()}::with", array($relations));
342
+
343
+		$model->whereHas('groups', function($q) use ($groupName){
344
+			$q->where('name', $groupName);
345
+		});
346 346
 
347 347
         
348
-        if (count($conditions['conditionValues']))
349
-        {
350
-            $model->whereRaw($conditions['conditionString'], $conditions['conditionValues']);
351
-        }
352
-
353
-        if ($perPage) 
354
-        {
355
-            return $model->orderBy($sortBy, $sort)->paginate($perPage);
356
-        }
357
-
358
-        return $model->orderBy($sortBy, $sort)->get();
359
-    }
360
-
361
-    /**
362
-     * Save the given data to the logged in user.
363
-     *
364
-     * @param  array $credentials
365
-     * @return void
366
-     */
367
-    public function saveProfile($data) 
368
-    {
369
-        if (array_key_exists('profile_picture', $data)) 
370
-        {
371
-            $data['profile_picture'] = \Media::uploadImageBas64($data['profile_picture'], 'admins/profile_pictures');
372
-        }
348
+		if (count($conditions['conditionValues']))
349
+		{
350
+			$model->whereRaw($conditions['conditionString'], $conditions['conditionValues']);
351
+		}
352
+
353
+		if ($perPage) 
354
+		{
355
+			return $model->orderBy($sortBy, $sort)->paginate($perPage);
356
+		}
357
+
358
+		return $model->orderBy($sortBy, $sort)->get();
359
+	}
360
+
361
+	/**
362
+	 * Save the given data to the logged in user.
363
+	 *
364
+	 * @param  array $credentials
365
+	 * @return void
366
+	 */
367
+	public function saveProfile($data) 
368
+	{
369
+		if (array_key_exists('profile_picture', $data)) 
370
+		{
371
+			$data['profile_picture'] = \Media::uploadImageBas64($data['profile_picture'], 'admins/profile_pictures');
372
+		}
373 373
         
374
-        $data['id'] = \Auth::id();
375
-        $this->save($data);
376
-    }
377
-
378
-    /**
379
-     * Ensure access token hasn't expired or revoked.
380
-     * 
381
-     * @param  string $accessToken
382
-     * @return boolean
383
-     */
384
-    public function accessTokenExpiredOrRevoked($accessToken)
385
-    {
386
-
387
-        $accessTokenRepository = \App::make('League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface');
388
-        $data = new ValidationData();
389
-        $data->setCurrentTime(time());
390
-
391
-        if ($accessToken->validate($data) === false || $accessTokenRepository->isAccessTokenRevoked($accessToken->getClaim('jti'))) 
392
-        {
393
-            return true;
394
-        }
395
-
396
-        return false;
397
-    }
374
+		$data['id'] = \Auth::id();
375
+		$this->save($data);
376
+	}
377
+
378
+	/**
379
+	 * Ensure access token hasn't expired or revoked.
380
+	 * 
381
+	 * @param  string $accessToken
382
+	 * @return boolean
383
+	 */
384
+	public function accessTokenExpiredOrRevoked($accessToken)
385
+	{
386
+
387
+		$accessTokenRepository = \App::make('League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface');
388
+		$data = new ValidationData();
389
+		$data->setCurrentTime(time());
390
+
391
+		if ($accessToken->validate($data) === false || $accessTokenRepository->isAccessTokenRevoked($accessToken->getClaim('jti'))) 
392
+		{
393
+			return true;
394
+		}
395
+
396
+		return false;
397
+	}
398 398
 }
Please login to merge, or discard this patch.
src/Modules/V1/Acl/AclPermission.php 1 patch
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -5,37 +5,37 @@
 block discarded – undo
5 5
 
6 6
 class AclPermission extends Model {
7 7
 
8
-    use SoftDeletes;
9
-    protected $table    = 'permissions';
10
-    protected $dates    = ['created_at', 'updated_at', 'deleted_at'];
11
-    protected $hidden   = ['deleted_at'];
12
-    protected $guarded  = ['id'];
13
-    protected $fillable = ['name', 'model'];
14
-    public $searchable  = ['name', 'model'];
8
+	use SoftDeletes;
9
+	protected $table    = 'permissions';
10
+	protected $dates    = ['created_at', 'updated_at', 'deleted_at'];
11
+	protected $hidden   = ['deleted_at'];
12
+	protected $guarded  = ['id'];
13
+	protected $fillable = ['name', 'model'];
14
+	public $searchable  = ['name', 'model'];
15 15
 
16
-    public function getCreatedAtAttribute($value)
17
-    {
18
-        return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
19
-    }
16
+	public function getCreatedAtAttribute($value)
17
+	{
18
+		return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
19
+	}
20 20
 
21
-    public function getUpdatedAtAttribute($value)
22
-    {
23
-        return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
24
-    }
21
+	public function getUpdatedAtAttribute($value)
22
+	{
23
+		return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
24
+	}
25 25
 
26
-    public function getDeletedAtAttribute($value)
27
-    {
28
-        return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
29
-    }
26
+	public function getDeletedAtAttribute($value)
27
+	{
28
+		return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString();
29
+	}
30 30
     
31
-    public function groups()
32
-    {
33
-        return $this->belongsToMany('\App\Modules\V1\Acl\AclGroup','groups_permissions','permission_id','group_id')->whereNull('groups_permissions.deleted_at')->withTimestamps();
34
-    }
31
+	public function groups()
32
+	{
33
+		return $this->belongsToMany('\App\Modules\V1\Acl\AclGroup','groups_permissions','permission_id','group_id')->whereNull('groups_permissions.deleted_at')->withTimestamps();
34
+	}
35 35
 
36
-    public static function boot()
37
-    {
38
-        parent::boot();
39
-        parent::observe(\App::make('App\Modules\V1\Acl\ModelObservers\AclPermissionObserver'));
40
-    }
36
+	public static function boot()
37
+	{
38
+		parent::boot();
39
+		parent::observe(\App::make('App\Modules\V1\Acl\ModelObservers\AclPermissionObserver'));
40
+	}
41 41
 }
Please login to merge, or discard this patch.