优化代码

This commit is contained in:
2026-01-19 13:07:02 +08:00
parent 51cfee33db
commit e3b7c63e5a
9 changed files with 157 additions and 67 deletions

View File

@@ -14,6 +14,8 @@ use Illuminate\Notifications\Notification;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
class Member extends Authenticatable implements JWTSubject {
use Notifiable;
@@ -59,7 +61,9 @@ class Member extends Authenticatable implements JWTSubject {
public function avatar(): Attribute {
return new Attribute(
get: fn ($value) => $value ?? request()->root() . '/storage/avatar/default_avatar.jpg',
get: function($value){
return $value ? (Str::startsWith($value, 'http') ? $value : Storage::url($value)) : '';
}
);
}