fix: sync employee photo to user profile avatar, topbar, and dashboard

This commit is contained in:
Ray1111-aa
2026-10-20 19:22:28 +07:00
parent 7126648c1c
commit cd3ce0c191
10 changed files with 424 additions and 49 deletions
+9 -4
View File
@@ -48,15 +48,20 @@ class Employee extends Model
public function getPhotoUrlAttribute(): ?string
{
if (!$this->photo_path) {
$path = $this->photo_path;
if (empty($path) && $this->user_id) {
$path = $this->user?->photo_path;
}
if (!$path) {
return null;
}
if (str_starts_with($this->photo_path, 'http://') || str_starts_with($this->photo_path, 'https://')) {
return $this->photo_path;
if (str_starts_with($path, 'http://') || str_starts_with($path, 'https://')) {
return $path;
}
return asset('storage/' . ltrim($this->photo_path, '/'));
return asset('storage/' . ltrim($path, '/'));
}
/**