Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Xinecraft committed Dec 23, 2023
1 parent 6b8edbc commit cbeb8a6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/Http/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 7 additions & 3 deletions app/Models/Role.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Spatie\MediaLibrary\HasMedia;
use Spatie\MediaLibrary\InteractsWithMedia;

Expand All @@ -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
Expand All @@ -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;
}
}

0 comments on commit cbeb8a6

Please sign in to comment.