more fixes
This commit is contained in:
@@ -11,6 +11,7 @@ use App\Models\SocialAccount;
|
||||
use App\Models\Conversation;
|
||||
use App\Models\ConversationParticipant;
|
||||
use App\Models\Message;
|
||||
use App\Models\Notification;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
@@ -30,6 +31,7 @@ class User extends Authenticatable
|
||||
protected $fillable = [
|
||||
'username',
|
||||
'username_changed_at',
|
||||
'last_username_change_at',
|
||||
'onboarding_step',
|
||||
'name',
|
||||
'email',
|
||||
@@ -38,6 +40,10 @@ class User extends Authenticatable
|
||||
'verification_send_window_started_at',
|
||||
'is_active',
|
||||
'needs_password_reset',
|
||||
'cover_hash',
|
||||
'cover_ext',
|
||||
'cover_position',
|
||||
'trust_score',
|
||||
'password',
|
||||
'role',
|
||||
'allow_messages_from',
|
||||
@@ -66,7 +72,10 @@ class User extends Authenticatable
|
||||
'verification_send_window_started_at' => 'datetime',
|
||||
'verification_send_count_24h' => 'integer',
|
||||
'username_changed_at' => 'datetime',
|
||||
'last_username_change_at' => 'datetime',
|
||||
'deleted_at' => 'datetime',
|
||||
'cover_position' => 'integer',
|
||||
'trust_score' => 'integer',
|
||||
'password' => 'hashed',
|
||||
'allow_messages_from' => 'string',
|
||||
];
|
||||
@@ -139,6 +148,19 @@ class User extends Authenticatable
|
||||
return $this->hasMany(Message::class, 'sender_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Skinbase notifications are keyed by user_id (non-polymorphic table).
|
||||
*/
|
||||
public function notifications(): HasMany
|
||||
{
|
||||
return $this->hasMany(Notification::class, 'user_id')->latest();
|
||||
}
|
||||
|
||||
public function unreadNotifications(): HasMany
|
||||
{
|
||||
return $this->notifications()->whereNull('read_at');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if this user allows receiving messages from the given user.
|
||||
*/
|
||||
@@ -221,6 +243,11 @@ class User extends Authenticatable
|
||||
return $this->hasMany(Post::class)->orderByDesc('created_at');
|
||||
}
|
||||
|
||||
public function stories(): HasMany
|
||||
{
|
||||
return $this->hasMany(Story::class, 'creator_id')->orderByDesc('published_at');
|
||||
}
|
||||
|
||||
// ─── Meilisearch ──────────────────────────────────────────────────────────
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user