@@ -8,27 +8,27 @@ |
||
| 8 | 8 | |
| 9 | 9 | class OauthClient extends Client |
| 10 | 10 | { |
| 11 | - protected $dates = ['created_at', 'updated_at']; |
|
| 12 | - protected $fillable = ['name', 'redirect', 'user_id', 'personal_access_client', 'password_client', 'revoked']; |
|
| 11 | + protected $dates = ['created_at', 'updated_at']; |
|
| 12 | + protected $fillable = ['name', 'redirect', 'user_id', 'personal_access_client', 'password_client', 'revoked']; |
|
| 13 | 13 | |
| 14 | - public function getCreatedAtAttribute($value) |
|
| 15 | - { |
|
| 16 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
| 17 | - } |
|
| 14 | + public function getCreatedAtAttribute($value) |
|
| 15 | + { |
|
| 16 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
| 17 | + } |
|
| 18 | 18 | |
| 19 | - public function getUpdatedAtAttribute($value) |
|
| 20 | - { |
|
| 21 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
| 22 | - } |
|
| 19 | + public function getUpdatedAtAttribute($value) |
|
| 20 | + { |
|
| 21 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
| 22 | + } |
|
| 23 | 23 | |
| 24 | - public function user() |
|
| 25 | - { |
|
| 26 | - return $this->belongsTo(AclUser::class); |
|
| 27 | - } |
|
| 24 | + public function user() |
|
| 25 | + { |
|
| 26 | + return $this->belongsTo(AclUser::class); |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - public static function boot() |
|
| 30 | - { |
|
| 31 | - parent::boot(); |
|
| 32 | - OauthClient::observe(OauthClientObserver::class); |
|
| 33 | - } |
|
| 29 | + public static function boot() |
|
| 30 | + { |
|
| 31 | + parent::boot(); |
|
| 32 | + OauthClient::observe(OauthClientObserver::class); |
|
| 33 | + } |
|
| 34 | 34 | } |
@@ -9,41 +9,41 @@ |
||
| 9 | 9 | class Role extends Model |
| 10 | 10 | { |
| 11 | 11 | |
| 12 | - use SoftDeletes; |
|
| 13 | - protected $table = 'roles'; |
|
| 14 | - protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
| 15 | - protected $hidden = ['deleted_at']; |
|
| 16 | - protected $guarded = ['id']; |
|
| 17 | - protected $fillable = ['name']; |
|
| 18 | - |
|
| 19 | - public function getCreatedAtAttribute($value) |
|
| 20 | - { |
|
| 21 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
| 22 | - } |
|
| 23 | - |
|
| 24 | - public function getUpdatedAtAttribute($value) |
|
| 25 | - { |
|
| 26 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
| 27 | - } |
|
| 28 | - |
|
| 29 | - public function getDeletedAtAttribute($value) |
|
| 30 | - { |
|
| 31 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
| 32 | - } |
|
| 33 | - |
|
| 34 | - public function users() |
|
| 35 | - { |
|
| 36 | - return $this->belongsToMany(AclUser::class, 'role_user', 'role_id', 'user_id')->whereNull('role_user.deleted_at')->withTimestamps(); |
|
| 37 | - } |
|
| 38 | - |
|
| 39 | - public function permissions() |
|
| 40 | - { |
|
| 41 | - return $this->belongsToMany(Permission::class, 'permission_role', 'role_id', 'permission_id')->whereNull('permission_role.deleted_at')->withTimestamps(); |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - public static function boot() |
|
| 45 | - { |
|
| 46 | - parent::boot(); |
|
| 47 | - Role::observe(RoleObserver::class); |
|
| 48 | - } |
|
| 12 | + use SoftDeletes; |
|
| 13 | + protected $table = 'roles'; |
|
| 14 | + protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
| 15 | + protected $hidden = ['deleted_at']; |
|
| 16 | + protected $guarded = ['id']; |
|
| 17 | + protected $fillable = ['name']; |
|
| 18 | + |
|
| 19 | + public function getCreatedAtAttribute($value) |
|
| 20 | + { |
|
| 21 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
| 22 | + } |
|
| 23 | + |
|
| 24 | + public function getUpdatedAtAttribute($value) |
|
| 25 | + { |
|
| 26 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
| 27 | + } |
|
| 28 | + |
|
| 29 | + public function getDeletedAtAttribute($value) |
|
| 30 | + { |
|
| 31 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
| 32 | + } |
|
| 33 | + |
|
| 34 | + public function users() |
|
| 35 | + { |
|
| 36 | + return $this->belongsToMany(AclUser::class, 'role_user', 'role_id', 'user_id')->whereNull('role_user.deleted_at')->withTimestamps(); |
|
| 37 | + } |
|
| 38 | + |
|
| 39 | + public function permissions() |
|
| 40 | + { |
|
| 41 | + return $this->belongsToMany(Permission::class, 'permission_role', 'role_id', 'permission_id')->whereNull('permission_role.deleted_at')->withTimestamps(); |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + public static function boot() |
|
| 45 | + { |
|
| 46 | + parent::boot(); |
|
| 47 | + Role::observe(RoleObserver::class); |
|
| 48 | + } |
|
| 49 | 49 | } |
@@ -11,132 +11,132 @@ |
||
| 11 | 11 | class AclUser extends User |
| 12 | 12 | { |
| 13 | 13 | |
| 14 | - use SoftDeletes, HasApiTokens; |
|
| 15 | - protected $table = 'users'; |
|
| 16 | - protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
| 17 | - protected $hidden = ['password', 'remember_token', 'deleted_at']; |
|
| 18 | - protected $guarded = ['id']; |
|
| 19 | - protected $fillable = ['profile_picture', 'name', 'email', 'password', 'locale', 'timezone']; |
|
| 14 | + use SoftDeletes, HasApiTokens; |
|
| 15 | + protected $table = 'users'; |
|
| 16 | + protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
| 17 | + protected $hidden = ['password', 'remember_token', 'deleted_at']; |
|
| 18 | + protected $guarded = ['id']; |
|
| 19 | + protected $fillable = ['profile_picture', 'name', 'email', 'password', 'locale', 'timezone']; |
|
| 20 | 20 | |
| 21 | - public function getCreatedAtAttribute($value) |
|
| 22 | - { |
|
| 23 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
| 24 | - } |
|
| 25 | - |
|
| 26 | - public function getUpdatedAtAttribute($value) |
|
| 27 | - { |
|
| 28 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
| 29 | - } |
|
| 30 | - |
|
| 31 | - public function getDeletedAtAttribute($value) |
|
| 32 | - { |
|
| 33 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
| 34 | - } |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * Get the profile picture url. |
|
| 38 | - * @return string |
|
| 39 | - */ |
|
| 40 | - public function getProfilePictureAttribute($value) |
|
| 41 | - { |
|
| 42 | - return url(\Storage::url($value)); |
|
| 43 | - } |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * Encrypt the password attribute before |
|
| 47 | - * saving it in the storage. |
|
| 48 | - * |
|
| 49 | - * @param string $value |
|
| 50 | - */ |
|
| 51 | - public function setPasswordAttribute($value) |
|
| 52 | - { |
|
| 53 | - $this->attributes['password'] = \Hash::make($value); |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - /** |
|
| 57 | - * Get the entity's notifications. |
|
| 58 | - */ |
|
| 59 | - public function notifications() |
|
| 60 | - { |
|
| 61 | - return $this->morphMany(Notification::class, 'notifiable')->orderBy('created_at', 'desc'); |
|
| 62 | - } |
|
| 63 | - |
|
| 64 | - /** |
|
| 65 | - * Get the entity's read notifications. |
|
| 66 | - */ |
|
| 67 | - public function readNotifications() |
|
| 68 | - { |
|
| 69 | - return $this->notifications()->whereNotNull('read_at'); |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - /** |
|
| 73 | - * Get the entity's unread notifications. |
|
| 74 | - */ |
|
| 75 | - public function unreadNotifications() |
|
| 76 | - { |
|
| 77 | - return $this->notifications()->whereNull('read_at'); |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - public function roles() |
|
| 81 | - { |
|
| 82 | - return $this->belongsToMany(Role::class, 'role_user', 'user_id', 'role_id')->whereNull('role_user.deleted_at')->withTimestamps(); |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - public function oauthClients() |
|
| 86 | - { |
|
| 87 | - return $this->hasMany(OauthClient::class, 'user_id'); |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - /** |
|
| 91 | - * Return fcm device tokens that will be used in sending fcm notifications. |
|
| 92 | - * |
|
| 93 | - * @return array |
|
| 94 | - */ |
|
| 95 | - public function routeNotificationForFCM() |
|
| 96 | - { |
|
| 97 | - $devices = \Core::pushNotificationDevices()->findBy(['user_id' => $this->id]); |
|
| 98 | - $tokens = []; |
|
| 99 | - |
|
| 100 | - foreach ($devices as $device) { |
|
| 101 | - if (\Core::oauthClients()->accessTokenExpiredOrRevoked($device->access_token)) { |
|
| 102 | - $device->forceDelete(); |
|
| 103 | - continue; |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - $tokens[] = $device->device_token; |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - return $tokens; |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - /** |
|
| 113 | - * The channels the user receives notification broadcasts on. |
|
| 114 | - * |
|
| 115 | - * @return string |
|
| 116 | - */ |
|
| 117 | - public function receivesBroadcastNotificationsOn() |
|
| 118 | - { |
|
| 119 | - return 'users.'.$this->id; |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - /** |
|
| 123 | - * Custom password validation. |
|
| 124 | - * |
|
| 125 | - * @param string $password |
|
| 126 | - * @return boolean |
|
| 127 | - */ |
|
| 128 | - public function validateForPassportPasswordGrant($password) |
|
| 129 | - { |
|
| 130 | - if ($password == config('skeleton.social_pass')) { |
|
| 131 | - return true; |
|
| 132 | - } |
|
| 133 | - |
|
| 134 | - return \Hash::check($password, $this->password); |
|
| 135 | - } |
|
| 21 | + public function getCreatedAtAttribute($value) |
|
| 22 | + { |
|
| 23 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
| 24 | + } |
|
| 25 | + |
|
| 26 | + public function getUpdatedAtAttribute($value) |
|
| 27 | + { |
|
| 28 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
| 29 | + } |
|
| 30 | + |
|
| 31 | + public function getDeletedAtAttribute($value) |
|
| 32 | + { |
|
| 33 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
| 34 | + } |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * Get the profile picture url. |
|
| 38 | + * @return string |
|
| 39 | + */ |
|
| 40 | + public function getProfilePictureAttribute($value) |
|
| 41 | + { |
|
| 42 | + return url(\Storage::url($value)); |
|
| 43 | + } |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * Encrypt the password attribute before |
|
| 47 | + * saving it in the storage. |
|
| 48 | + * |
|
| 49 | + * @param string $value |
|
| 50 | + */ |
|
| 51 | + public function setPasswordAttribute($value) |
|
| 52 | + { |
|
| 53 | + $this->attributes['password'] = \Hash::make($value); |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + /** |
|
| 57 | + * Get the entity's notifications. |
|
| 58 | + */ |
|
| 59 | + public function notifications() |
|
| 60 | + { |
|
| 61 | + return $this->morphMany(Notification::class, 'notifiable')->orderBy('created_at', 'desc'); |
|
| 62 | + } |
|
| 63 | + |
|
| 64 | + /** |
|
| 65 | + * Get the entity's read notifications. |
|
| 66 | + */ |
|
| 67 | + public function readNotifications() |
|
| 68 | + { |
|
| 69 | + return $this->notifications()->whereNotNull('read_at'); |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + /** |
|
| 73 | + * Get the entity's unread notifications. |
|
| 74 | + */ |
|
| 75 | + public function unreadNotifications() |
|
| 76 | + { |
|
| 77 | + return $this->notifications()->whereNull('read_at'); |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + public function roles() |
|
| 81 | + { |
|
| 82 | + return $this->belongsToMany(Role::class, 'role_user', 'user_id', 'role_id')->whereNull('role_user.deleted_at')->withTimestamps(); |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + public function oauthClients() |
|
| 86 | + { |
|
| 87 | + return $this->hasMany(OauthClient::class, 'user_id'); |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + /** |
|
| 91 | + * Return fcm device tokens that will be used in sending fcm notifications. |
|
| 92 | + * |
|
| 93 | + * @return array |
|
| 94 | + */ |
|
| 95 | + public function routeNotificationForFCM() |
|
| 96 | + { |
|
| 97 | + $devices = \Core::pushNotificationDevices()->findBy(['user_id' => $this->id]); |
|
| 98 | + $tokens = []; |
|
| 99 | + |
|
| 100 | + foreach ($devices as $device) { |
|
| 101 | + if (\Core::oauthClients()->accessTokenExpiredOrRevoked($device->access_token)) { |
|
| 102 | + $device->forceDelete(); |
|
| 103 | + continue; |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + $tokens[] = $device->device_token; |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + return $tokens; |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + /** |
|
| 113 | + * The channels the user receives notification broadcasts on. |
|
| 114 | + * |
|
| 115 | + * @return string |
|
| 116 | + */ |
|
| 117 | + public function receivesBroadcastNotificationsOn() |
|
| 118 | + { |
|
| 119 | + return 'users.'.$this->id; |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + /** |
|
| 123 | + * Custom password validation. |
|
| 124 | + * |
|
| 125 | + * @param string $password |
|
| 126 | + * @return boolean |
|
| 127 | + */ |
|
| 128 | + public function validateForPassportPasswordGrant($password) |
|
| 129 | + { |
|
| 130 | + if ($password == config('skeleton.social_pass')) { |
|
| 131 | + return true; |
|
| 132 | + } |
|
| 133 | + |
|
| 134 | + return \Hash::check($password, $this->password); |
|
| 135 | + } |
|
| 136 | 136 | |
| 137 | - public static function boot() |
|
| 138 | - { |
|
| 139 | - parent::boot(); |
|
| 140 | - AclUser::observe(AclUserObserver::class); |
|
| 141 | - } |
|
| 137 | + public static function boot() |
|
| 138 | + { |
|
| 139 | + parent::boot(); |
|
| 140 | + AclUser::observe(AclUserObserver::class); |
|
| 141 | + } |
|
| 142 | 142 | } |
@@ -7,31 +7,31 @@ |
||
| 7 | 7 | class Report extends Model |
| 8 | 8 | { |
| 9 | 9 | |
| 10 | - use SoftDeletes; |
|
| 11 | - protected $table = 'reports'; |
|
| 12 | - protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
| 13 | - protected $hidden = ['deleted_at']; |
|
| 14 | - protected $guarded = ['id']; |
|
| 15 | - protected $fillable = ['report_name', 'view_name']; |
|
| 10 | + use SoftDeletes; |
|
| 11 | + protected $table = 'reports'; |
|
| 12 | + protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
| 13 | + protected $hidden = ['deleted_at']; |
|
| 14 | + protected $guarded = ['id']; |
|
| 15 | + protected $fillable = ['report_name', 'view_name']; |
|
| 16 | 16 | |
| 17 | - public function getCreatedAtAttribute($value) |
|
| 18 | - { |
|
| 19 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
| 20 | - } |
|
| 17 | + public function getCreatedAtAttribute($value) |
|
| 18 | + { |
|
| 19 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
| 20 | + } |
|
| 21 | 21 | |
| 22 | - public function getUpdatedAtAttribute($value) |
|
| 23 | - { |
|
| 24 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
| 25 | - } |
|
| 22 | + public function getUpdatedAtAttribute($value) |
|
| 23 | + { |
|
| 24 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
| 25 | + } |
|
| 26 | 26 | |
| 27 | - public function getDeletedAtAttribute($value) |
|
| 28 | - { |
|
| 29 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
| 30 | - } |
|
| 27 | + public function getDeletedAtAttribute($value) |
|
| 28 | + { |
|
| 29 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | - public static function boot() |
|
| 33 | - { |
|
| 34 | - parent::boot(); |
|
| 35 | - Report::observe(ReportObserver::class); |
|
| 36 | - } |
|
| 32 | + public static function boot() |
|
| 33 | + { |
|
| 34 | + parent::boot(); |
|
| 35 | + Report::observe(ReportObserver::class); |
|
| 36 | + } |
|
| 37 | 37 | } |
@@ -2,93 +2,93 @@ |
||
| 2 | 2 | |
| 3 | 3 | interface BaseRepositoryInterface |
| 4 | 4 | { |
| 5 | - /** |
|
| 6 | - * Fetch all records with relations from the storage. |
|
| 7 | - * |
|
| 8 | - * @param array $relations |
|
| 9 | - * @param array $sortBy |
|
| 10 | - * @param array $desc |
|
| 11 | - * @param array $columns |
|
| 12 | - * @return collection |
|
| 13 | - */ |
|
| 14 | - public function all($relations = [], $sortBy = 'created_at', $desc = 0, $columns = ['*']); |
|
| 5 | + /** |
|
| 6 | + * Fetch all records with relations from the storage. |
|
| 7 | + * |
|
| 8 | + * @param array $relations |
|
| 9 | + * @param array $sortBy |
|
| 10 | + * @param array $desc |
|
| 11 | + * @param array $columns |
|
| 12 | + * @return collection |
|
| 13 | + */ |
|
| 14 | + public function all($relations = [], $sortBy = 'created_at', $desc = 0, $columns = ['*']); |
|
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * Fetch all records with relations from storage in pages. |
|
| 18 | - * |
|
| 19 | - * @param integer $perPage |
|
| 20 | - * @param array $relations |
|
| 21 | - * @param array $sortBy |
|
| 22 | - * @param array $desc |
|
| 23 | - * @param array $columns |
|
| 24 | - * @return collection |
|
| 25 | - */ |
|
| 26 | - public function paginate($perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = ['*']); |
|
| 16 | + /** |
|
| 17 | + * Fetch all records with relations from storage in pages. |
|
| 18 | + * |
|
| 19 | + * @param integer $perPage |
|
| 20 | + * @param array $relations |
|
| 21 | + * @param array $sortBy |
|
| 22 | + * @param array $desc |
|
| 23 | + * @param array $columns |
|
| 24 | + * @return collection |
|
| 25 | + */ |
|
| 26 | + public function paginate($perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = ['*']); |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * Fetch all records with relations based on |
|
| 30 | - * the given condition from storage in pages. |
|
| 31 | - * |
|
| 32 | - * @param array $conditions array of conditions |
|
| 33 | - * @param integer $perPage |
|
| 34 | - * @param array $relations |
|
| 35 | - * @param array $sortBy |
|
| 36 | - * @param array $desc |
|
| 37 | - * @param array $columns |
|
| 38 | - * @return collection |
|
| 39 | - */ |
|
| 40 | - public function paginateBy($conditions, $perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = ['*']); |
|
| 28 | + /** |
|
| 29 | + * Fetch all records with relations based on |
|
| 30 | + * the given condition from storage in pages. |
|
| 31 | + * |
|
| 32 | + * @param array $conditions array of conditions |
|
| 33 | + * @param integer $perPage |
|
| 34 | + * @param array $relations |
|
| 35 | + * @param array $sortBy |
|
| 36 | + * @param array $desc |
|
| 37 | + * @param array $columns |
|
| 38 | + * @return collection |
|
| 39 | + */ |
|
| 40 | + public function paginateBy($conditions, $perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = ['*']); |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * Save the given model/models to the storage. |
|
| 44 | - * |
|
| 45 | - * @param array $data |
|
| 46 | - * @return mixed |
|
| 47 | - */ |
|
| 48 | - public function save(array $data); |
|
| 42 | + /** |
|
| 43 | + * Save the given model/models to the storage. |
|
| 44 | + * |
|
| 45 | + * @param array $data |
|
| 46 | + * @return mixed |
|
| 47 | + */ |
|
| 48 | + public function save(array $data); |
|
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * Delete record from the storage based on the given |
|
| 52 | - * condition. |
|
| 53 | - * |
|
| 54 | - * @param var $value condition value |
|
| 55 | - * @param string $attribute condition column name |
|
| 56 | - * @return integer affected rows |
|
| 57 | - */ |
|
| 58 | - public function delete($value, $attribute = 'id'); |
|
| 50 | + /** |
|
| 51 | + * Delete record from the storage based on the given |
|
| 52 | + * condition. |
|
| 53 | + * |
|
| 54 | + * @param var $value condition value |
|
| 55 | + * @param string $attribute condition column name |
|
| 56 | + * @return integer affected rows |
|
| 57 | + */ |
|
| 58 | + public function delete($value, $attribute = 'id'); |
|
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * Fetch records from the storage based on the given |
|
| 62 | - * id. |
|
| 63 | - * |
|
| 64 | - * @param integer $id |
|
| 65 | - * @param array $relations |
|
| 66 | - * @param array $columns |
|
| 67 | - * @return object |
|
| 68 | - */ |
|
| 69 | - public function find($id, $relations = [], $columns = ['*']); |
|
| 60 | + /** |
|
| 61 | + * Fetch records from the storage based on the given |
|
| 62 | + * id. |
|
| 63 | + * |
|
| 64 | + * @param integer $id |
|
| 65 | + * @param array $relations |
|
| 66 | + * @param array $columns |
|
| 67 | + * @return object |
|
| 68 | + */ |
|
| 69 | + public function find($id, $relations = [], $columns = ['*']); |
|
| 70 | 70 | |
| 71 | - /** |
|
| 72 | - * Fetch records from the storage based on the given |
|
| 73 | - * condition. |
|
| 74 | - * |
|
| 75 | - * @param array $conditions array of conditions |
|
| 76 | - * @param array $relations |
|
| 77 | - * @param array $sortBy |
|
| 78 | - * @param array $desc |
|
| 79 | - * @param array $columns |
|
| 80 | - * @return collection |
|
| 81 | - */ |
|
| 82 | - public function findBy($conditions, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = ['*']); |
|
| 71 | + /** |
|
| 72 | + * Fetch records from the storage based on the given |
|
| 73 | + * condition. |
|
| 74 | + * |
|
| 75 | + * @param array $conditions array of conditions |
|
| 76 | + * @param array $relations |
|
| 77 | + * @param array $sortBy |
|
| 78 | + * @param array $desc |
|
| 79 | + * @param array $columns |
|
| 80 | + * @return collection |
|
| 81 | + */ |
|
| 82 | + public function findBy($conditions, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = ['*']); |
|
| 83 | 83 | |
| 84 | - /** |
|
| 85 | - * Fetch the first record fro the storage based on the given |
|
| 86 | - * condition. |
|
| 87 | - * |
|
| 88 | - * @param array $conditions array of conditions |
|
| 89 | - * @param array $relations |
|
| 90 | - * @param array $columns |
|
| 91 | - * @return object |
|
| 92 | - */ |
|
| 93 | - public function first($conditions, $relations = [], $columns = ['*']); |
|
| 84 | + /** |
|
| 85 | + * Fetch the first record fro the storage based on the given |
|
| 86 | + * condition. |
|
| 87 | + * |
|
| 88 | + * @param array $conditions array of conditions |
|
| 89 | + * @param array $relations |
|
| 90 | + * @param array $columns |
|
| 91 | + * @return object |
|
| 92 | + */ |
|
| 93 | + public function first($conditions, $relations = [], $columns = ['*']); |
|
| 94 | 94 | } |
@@ -2,93 +2,93 @@ |
||
| 2 | 2 | |
| 3 | 3 | interface BaseServiceInterface |
| 4 | 4 | { |
| 5 | - /** |
|
| 6 | - * Fetch all records with relations from the storage. |
|
| 7 | - * |
|
| 8 | - * @param array $relations |
|
| 9 | - * @param array $sortBy |
|
| 10 | - * @param array $desc |
|
| 11 | - * @param array $columns |
|
| 12 | - * @return collection |
|
| 13 | - */ |
|
| 14 | - public function all($relations = [], $sortBy = 'created_at', $desc = 0, $columns = ['*']); |
|
| 5 | + /** |
|
| 6 | + * Fetch all records with relations from the storage. |
|
| 7 | + * |
|
| 8 | + * @param array $relations |
|
| 9 | + * @param array $sortBy |
|
| 10 | + * @param array $desc |
|
| 11 | + * @param array $columns |
|
| 12 | + * @return collection |
|
| 13 | + */ |
|
| 14 | + public function all($relations = [], $sortBy = 'created_at', $desc = 0, $columns = ['*']); |
|
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * Fetch all records with relations from storage in pages. |
|
| 18 | - * |
|
| 19 | - * @param integer $perPage |
|
| 20 | - * @param array $relations |
|
| 21 | - * @param array $sortBy |
|
| 22 | - * @param array $desc |
|
| 23 | - * @param array $columns |
|
| 24 | - * @return collection |
|
| 25 | - */ |
|
| 26 | - public function paginate($perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = ['*']); |
|
| 16 | + /** |
|
| 17 | + * Fetch all records with relations from storage in pages. |
|
| 18 | + * |
|
| 19 | + * @param integer $perPage |
|
| 20 | + * @param array $relations |
|
| 21 | + * @param array $sortBy |
|
| 22 | + * @param array $desc |
|
| 23 | + * @param array $columns |
|
| 24 | + * @return collection |
|
| 25 | + */ |
|
| 26 | + public function paginate($perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = ['*']); |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * Fetch all records with relations based on |
|
| 30 | - * the given condition from storage in pages. |
|
| 31 | - * |
|
| 32 | - * @param array $conditions array of conditions |
|
| 33 | - * @param integer $perPage |
|
| 34 | - * @param array $relations |
|
| 35 | - * @param array $sortBy |
|
| 36 | - * @param array $desc |
|
| 37 | - * @param array $columns |
|
| 38 | - * @return collection |
|
| 39 | - */ |
|
| 40 | - public function paginateBy($conditions, $perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = ['*']); |
|
| 28 | + /** |
|
| 29 | + * Fetch all records with relations based on |
|
| 30 | + * the given condition from storage in pages. |
|
| 31 | + * |
|
| 32 | + * @param array $conditions array of conditions |
|
| 33 | + * @param integer $perPage |
|
| 34 | + * @param array $relations |
|
| 35 | + * @param array $sortBy |
|
| 36 | + * @param array $desc |
|
| 37 | + * @param array $columns |
|
| 38 | + * @return collection |
|
| 39 | + */ |
|
| 40 | + public function paginateBy($conditions, $perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = ['*']); |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * Save the given model/models to the storage. |
|
| 44 | - * |
|
| 45 | - * @param array $data |
|
| 46 | - * @return mixed |
|
| 47 | - */ |
|
| 48 | - public function save(array $data); |
|
| 42 | + /** |
|
| 43 | + * Save the given model/models to the storage. |
|
| 44 | + * |
|
| 45 | + * @param array $data |
|
| 46 | + * @return mixed |
|
| 47 | + */ |
|
| 48 | + public function save(array $data); |
|
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * Delete record from the storage based on the given |
|
| 52 | - * condition. |
|
| 53 | - * |
|
| 54 | - * @param var $value condition value |
|
| 55 | - * @param string $attribute condition column name |
|
| 56 | - * @return integer affected rows |
|
| 57 | - */ |
|
| 58 | - public function delete($value, $attribute = 'id'); |
|
| 50 | + /** |
|
| 51 | + * Delete record from the storage based on the given |
|
| 52 | + * condition. |
|
| 53 | + * |
|
| 54 | + * @param var $value condition value |
|
| 55 | + * @param string $attribute condition column name |
|
| 56 | + * @return integer affected rows |
|
| 57 | + */ |
|
| 58 | + public function delete($value, $attribute = 'id'); |
|
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * Fetch records from the storage based on the given |
|
| 62 | - * id. |
|
| 63 | - * |
|
| 64 | - * @param integer $id |
|
| 65 | - * @param array $relations |
|
| 66 | - * @param array $columns |
|
| 67 | - * @return object |
|
| 68 | - */ |
|
| 69 | - public function find($id, $relations = [], $columns = ['*']); |
|
| 60 | + /** |
|
| 61 | + * Fetch records from the storage based on the given |
|
| 62 | + * id. |
|
| 63 | + * |
|
| 64 | + * @param integer $id |
|
| 65 | + * @param array $relations |
|
| 66 | + * @param array $columns |
|
| 67 | + * @return object |
|
| 68 | + */ |
|
| 69 | + public function find($id, $relations = [], $columns = ['*']); |
|
| 70 | 70 | |
| 71 | - /** |
|
| 72 | - * Fetch records from the storage based on the given |
|
| 73 | - * condition. |
|
| 74 | - * |
|
| 75 | - * @param array $conditions array of conditions |
|
| 76 | - * @param array $relations |
|
| 77 | - * @param array $sortBy |
|
| 78 | - * @param array $desc |
|
| 79 | - * @param array $columns |
|
| 80 | - * @return collection |
|
| 81 | - */ |
|
| 82 | - public function findBy($conditions, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = ['*']); |
|
| 71 | + /** |
|
| 72 | + * Fetch records from the storage based on the given |
|
| 73 | + * condition. |
|
| 74 | + * |
|
| 75 | + * @param array $conditions array of conditions |
|
| 76 | + * @param array $relations |
|
| 77 | + * @param array $sortBy |
|
| 78 | + * @param array $desc |
|
| 79 | + * @param array $columns |
|
| 80 | + * @return collection |
|
| 81 | + */ |
|
| 82 | + public function findBy($conditions, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = ['*']); |
|
| 83 | 83 | |
| 84 | - /** |
|
| 85 | - * Fetch the first record fro the storage based on the given |
|
| 86 | - * condition. |
|
| 87 | - * |
|
| 88 | - * @param array $conditions array of conditions |
|
| 89 | - * @param array $relations |
|
| 90 | - * @param array $columns |
|
| 91 | - * @return object |
|
| 92 | - */ |
|
| 93 | - public function first($conditions, $relations = [], $columns = ['*']); |
|
| 84 | + /** |
|
| 85 | + * Fetch the first record fro the storage based on the given |
|
| 86 | + * condition. |
|
| 87 | + * |
|
| 88 | + * @param array $conditions array of conditions |
|
| 89 | + * @param array $relations |
|
| 90 | + * @param array $columns |
|
| 91 | + * @return object |
|
| 92 | + */ |
|
| 93 | + public function first($conditions, $relations = [], $columns = ['*']); |
|
| 94 | 94 | } |
@@ -3,7 +3,6 @@ |
||
| 3 | 3 | namespace App\Modules\Users\Repositories; |
| 4 | 4 | |
| 5 | 5 | use App\Modules\Core\BaseClasses\BaseRepository; |
| 6 | -use Illuminate\Support\Arr; |
|
| 7 | 6 | use App\Modules\Users\AclUser; |
| 8 | 7 | |
| 9 | 8 | class UserRepository extends BaseRepository |
@@ -6,52 +6,52 @@ |
||
| 6 | 6 | |
| 7 | 7 | class UserRepository extends BaseRepository |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * Init new object. |
|
| 11 | - * |
|
| 12 | - * @param AclUser $model |
|
| 13 | - * @return void |
|
| 14 | - */ |
|
| 15 | - public function __construct(AclUser $model) |
|
| 16 | - { |
|
| 17 | - parent::__construct($model); |
|
| 18 | - } |
|
| 9 | + /** |
|
| 10 | + * Init new object. |
|
| 11 | + * |
|
| 12 | + * @param AclUser $model |
|
| 13 | + * @return void |
|
| 14 | + */ |
|
| 15 | + public function __construct(AclUser $model) |
|
| 16 | + { |
|
| 17 | + parent::__construct($model); |
|
| 18 | + } |
|
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * Detach all roles from the given role. |
|
| 22 | - * |
|
| 23 | - * @param mixed $role |
|
| 24 | - * @return object |
|
| 25 | - */ |
|
| 26 | - public function detachRoles($role) |
|
| 27 | - { |
|
| 28 | - $role = ! is_int($role) ? $role : $this->find($role); |
|
| 29 | - $role->roles()->detach(); |
|
| 30 | - } |
|
| 20 | + /** |
|
| 21 | + * Detach all roles from the given role. |
|
| 22 | + * |
|
| 23 | + * @param mixed $role |
|
| 24 | + * @return object |
|
| 25 | + */ |
|
| 26 | + public function detachRoles($role) |
|
| 27 | + { |
|
| 28 | + $role = ! is_int($role) ? $role : $this->find($role); |
|
| 29 | + $role->roles()->detach(); |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * Attach role ids to the given role. |
|
| 34 | - * |
|
| 35 | - * @param mixed $role |
|
| 36 | - * @param array $roleIds |
|
| 37 | - * @return object |
|
| 38 | - */ |
|
| 39 | - public function attachRoles($role, $roleIds) |
|
| 40 | - { |
|
| 41 | - $role = ! is_int($role) ? $role : $this->find($role); |
|
| 42 | - $role->roles()->attach($roleIds); |
|
| 43 | - } |
|
| 32 | + /** |
|
| 33 | + * Attach role ids to the given role. |
|
| 34 | + * |
|
| 35 | + * @param mixed $role |
|
| 36 | + * @param array $roleIds |
|
| 37 | + * @return object |
|
| 38 | + */ |
|
| 39 | + public function attachRoles($role, $roleIds) |
|
| 40 | + { |
|
| 41 | + $role = ! is_int($role) ? $role : $this->find($role); |
|
| 42 | + $role->roles()->attach($roleIds); |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * Count the given user the given roles. |
|
| 47 | - * |
|
| 48 | - * @param mixed $user |
|
| 49 | - * @param string[] $roles |
|
| 50 | - * @return boolean |
|
| 51 | - */ |
|
| 52 | - public function countRoles($user, $roles) |
|
| 53 | - { |
|
| 54 | - $user = ! is_int($user) ? $user : $this->find($user); |
|
| 55 | - return $user->roles()->whereIn('name', $roles)->count(); |
|
| 56 | - } |
|
| 45 | + /** |
|
| 46 | + * Count the given user the given roles. |
|
| 47 | + * |
|
| 48 | + * @param mixed $user |
|
| 49 | + * @param string[] $roles |
|
| 50 | + * @return boolean |
|
| 51 | + */ |
|
| 52 | + public function countRoles($user, $roles) |
|
| 53 | + { |
|
| 54 | + $user = ! is_int($user) ? $user : $this->find($user); |
|
| 55 | + return $user->roles()->whereIn('name', $roles)->count(); |
|
| 56 | + } |
|
| 57 | 57 | } |
@@ -2,8 +2,8 @@ |
||
| 2 | 2 | |
| 3 | 3 | return [ |
| 4 | 4 | |
| 5 | - /** |
|
| 6 | - * Here goes your error messages. |
|
| 7 | - */ |
|
| 5 | + /** |
|
| 6 | + * Here goes your error messages. |
|
| 7 | + */ |
|
| 8 | 8 | |
| 9 | 9 | ]; |
@@ -10,36 +10,36 @@ |
||
| 10 | 10 | class Permission extends Model |
| 11 | 11 | { |
| 12 | 12 | |
| 13 | - use SoftDeletes; |
|
| 14 | - protected $table = 'permissions'; |
|
| 15 | - protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
| 16 | - protected $hidden = ['deleted_at']; |
|
| 17 | - protected $guarded = ['id']; |
|
| 18 | - protected $fillable = ['name', 'model']; |
|
| 19 | - |
|
| 20 | - public function getCreatedAtAttribute($value) |
|
| 21 | - { |
|
| 22 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
| 23 | - } |
|
| 24 | - |
|
| 25 | - public function getUpdatedAtAttribute($value) |
|
| 26 | - { |
|
| 27 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
| 28 | - } |
|
| 29 | - |
|
| 30 | - public function getDeletedAtAttribute($value) |
|
| 31 | - { |
|
| 32 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
| 33 | - } |
|
| 13 | + use SoftDeletes; |
|
| 14 | + protected $table = 'permissions'; |
|
| 15 | + protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
| 16 | + protected $hidden = ['deleted_at']; |
|
| 17 | + protected $guarded = ['id']; |
|
| 18 | + protected $fillable = ['name', 'model']; |
|
| 19 | + |
|
| 20 | + public function getCreatedAtAttribute($value) |
|
| 21 | + { |
|
| 22 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
| 23 | + } |
|
| 24 | + |
|
| 25 | + public function getUpdatedAtAttribute($value) |
|
| 26 | + { |
|
| 27 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
| 28 | + } |
|
| 29 | + |
|
| 30 | + public function getDeletedAtAttribute($value) |
|
| 31 | + { |
|
| 32 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - public function roles() |
|
| 36 | - { |
|
| 37 | - return $this->belongsToMany(Role::class, 'permission_role', 'permission_id', 'role_id')->whereNull('permission_role.deleted_at')->withTimestamps(); |
|
| 38 | - } |
|
| 39 | - |
|
| 40 | - public static function boot() |
|
| 41 | - { |
|
| 42 | - parent::boot(); |
|
| 43 | - Permission::observe(PermissionObserver::class); |
|
| 44 | - } |
|
| 35 | + public function roles() |
|
| 36 | + { |
|
| 37 | + return $this->belongsToMany(Role::class, 'permission_role', 'permission_id', 'role_id')->whereNull('permission_role.deleted_at')->withTimestamps(); |
|
| 38 | + } |
|
| 39 | + |
|
| 40 | + public static function boot() |
|
| 41 | + { |
|
| 42 | + parent::boot(); |
|
| 43 | + Permission::observe(PermissionObserver::class); |
|
| 44 | + } |
|
| 45 | 45 | } |