diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index c81f9ef6e..3c6ac78e1 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -26,7 +26,7 @@ public function indexStaff(): \Inertia\Response ->orderByDesc('weight'); }) ->select(['id', 'name', 'username', 'profile_photo_path', 'verified_at']) - ->dumpRawSql()->get(); + ->get(); return Inertia::render('User/IndexStaff', [ 'staffs' => $staffsWithRole, diff --git a/app/Models/Role.php b/app/Models/Role.php index 0a68d8c14..b955c76b0 100644 --- a/app/Models/Role.php +++ b/app/Models/Role.php @@ -2,7 +2,6 @@ namespace App\Models; -use Illuminate\Database\Eloquent\Factories\HasFactory; use Spatie\MediaLibrary\HasMedia; use Spatie\MediaLibrary\InteractsWithMedia; @@ -11,12 +10,16 @@ class Role extends \Spatie\Permission\Models\Role implements HasMedia use InteractsWithMedia; protected $appends = ['photo_url']; + protected $with = ['media']; + protected $casts = [ - 'is_staff' => 'boolean' + 'is_staff' => 'boolean', + 'is_hidden_from_staff_list' => 'boolean', ]; const DEFAULT_ROLE_NAME = 'default'; + const SUPER_ADMIN_ROLE_NAME = 'superadmin'; // For spatie/laravel-permissions https://github.com/spatie/laravel-permission/issues/1540 @@ -30,10 +33,11 @@ public function registerMediaCollections(): void public function getPhotoUrlAttribute() { - $photo_url = url('images/default-roles/'. $this->name. '.png'); + $photo_url = url('images/default-roles/'.$this->name.'.png'); if ($this->getFirstMediaUrl('role')) { $photo_url = $this->getFirstMediaUrl('role'); } + return $photo_url; } }