优化代码
This commit is contained in:
@@ -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)) : '';
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user