Files
SkinbaseNova/app/Models/UserProfile.php
2026-02-17 17:14:43 +01:00

55 lines
1.1 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use App\Support\AvatarUrl;
class UserProfile extends Model
{
protected $table = 'user_profiles';
protected $primaryKey = 'user_id';
public $incrementing = false;
protected $keyType = 'int';
protected $fillable = [
'user_id',
'about',
'signature',
'description',
'avatar_legacy',
'avatar_hash',
'avatar_mime',
'avatar_updated_at',
'cover_image',
'country',
'country_code',
'language',
'birthdate',
'gender',
'website',
];
protected $casts = [
'birthdate' => 'date',
'avatar_updated_at' => 'datetime',
];
public $timestamps = true;
public function user(): BelongsTo
{
return $this->belongsTo(User::class, 'user_id');
}
public function getAvatarUrlAttribute(): ?string
{
if (empty($this->user_id)) {
return null;
}
return AvatarUrl::forUser((int) $this->user_id, $this->avatar_hash, 128);
}
}