color
293 }
294
295
296 public function color(): string297 {
298 return match ($this->name) {
299 self::SYS_ADMIN => 'pink',
objects
147 ->withPivot(['object_id', 'workshop_id'])->using(RoleUser::class);
148 }
149
150 public function objects(): HasMany151 {
152 return $this->hasMany(RoleObject::class, 'role_id');
153 }
users
141
142 public $timestamps = false;
143
144 public function users(): BelongsToMany145 {
146 return $this->belongsToMany(User::class, 'role_users')
147 ->withPivot(['object_id', 'workshop_id'])->using(RoleUser::class);
roles
14 */
15trait HasRoles
16{
17 abstract public function roles(): BelongsToMany; 18
19 /**
20 * Scope a query to only include users with the given role.
before
14{
15 use HandlesAuthorization;
16
17 public function before(User $user) 18 {
19 if ($user->isAdmin()) {
20 return true;
Documentation comments are helpful in understanding what that part of the code is responsible for. It is always a good idea to add documentation to your code to improve the code readability and maintainability. In addition to that, it becomes helpful when you revisit the code after a long time. Here, the function/class method is missing the doc comment and it is recommended to add it for the reasons discussed above.