add profile pictures & (attempt) fix uploads

This commit is contained in:
yuriko 🦊 2025-05-24 22:43:03 -04:00
parent 2aa0689720
commit bb15fc96b4
8 changed files with 92 additions and 9 deletions

View file

@ -4,6 +4,7 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Notifications\Notifiable;
use Illuminate\Support\Facades\Storage;
use Laravel\Sanctum\HasApiTokens;
use MongoDB\Laravel\Auth\User as Authenticatable;
use MongoDB\Laravel\Relations\HasMany;
@ -21,6 +22,7 @@ class User extends Authenticatable implements Searchable
protected $fillable = [
'name',
'email',
'avatarExt',
];
protected $hidden = [
@ -55,4 +57,12 @@ class User extends Authenticatable implements Searchable
$url
);
}
public function getAvatarBase64(): string
{
$ext = $this->avatarExt;
$file = Storage::get("avatars/$this->id");
$data = base64_encode($file);
return "data:image/$ext;base64,$data";
}
}