optimizations
This commit is contained in:
@@ -15,6 +15,7 @@ use App\Models\Message;
|
||||
use App\Models\Notification;
|
||||
use App\Models\Achievement;
|
||||
use App\Models\UserAchievement;
|
||||
use App\Models\UserActivity;
|
||||
use App\Models\UserXpLog;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
@@ -25,7 +26,10 @@ use Laravel\Scout\Searchable;
|
||||
class User extends Authenticatable
|
||||
{
|
||||
/** @use HasFactory<\Database\Factories\UserFactory> */
|
||||
use HasFactory, Notifiable, SoftDeletes, Searchable;
|
||||
use HasFactory, Notifiable, SoftDeletes;
|
||||
use Searchable {
|
||||
Searchable::bootSearchable as private bootScoutSearchable;
|
||||
}
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
@@ -59,6 +63,7 @@ class User extends Authenticatable
|
||||
'rank',
|
||||
'password',
|
||||
'role',
|
||||
'nova_featured_creator',
|
||||
'allow_messages_from',
|
||||
];
|
||||
|
||||
@@ -81,6 +86,7 @@ class User extends Authenticatable
|
||||
{
|
||||
return [
|
||||
'email_verified_at' => 'datetime',
|
||||
'last_visit_at' => 'datetime',
|
||||
'last_verification_sent_at' => 'datetime',
|
||||
'verification_send_window_started_at' => 'datetime',
|
||||
'verification_send_count_24h' => 'integer',
|
||||
@@ -98,16 +104,32 @@ class User extends Authenticatable
|
||||
'xp' => 'integer',
|
||||
'level' => 'integer',
|
||||
'rank' => 'string',
|
||||
'nova_featured_creator' => 'boolean',
|
||||
'password' => 'hashed',
|
||||
'allow_messages_from' => 'string',
|
||||
];
|
||||
}
|
||||
|
||||
public function novaCards(): HasMany
|
||||
{
|
||||
return $this->hasMany(NovaCard::class);
|
||||
}
|
||||
|
||||
public function artworks(): HasMany
|
||||
{
|
||||
return $this->hasMany(Artwork::class);
|
||||
}
|
||||
|
||||
public function collections(): HasMany
|
||||
{
|
||||
return $this->hasMany(Collection::class)->latest('updated_at');
|
||||
}
|
||||
|
||||
public function savedCollectionLists(): HasMany
|
||||
{
|
||||
return $this->hasMany(CollectionSavedList::class, 'user_id')->orderBy('title');
|
||||
}
|
||||
|
||||
public function socialAccounts(): HasMany
|
||||
{
|
||||
return $this->hasMany(SocialAccount::class);
|
||||
@@ -170,6 +192,11 @@ class User extends Authenticatable
|
||||
return $this->hasMany(UserAchievement::class, 'user_id');
|
||||
}
|
||||
|
||||
public function userActivities(): HasMany
|
||||
{
|
||||
return $this->hasMany(UserActivity::class, 'user_id');
|
||||
}
|
||||
|
||||
public function achievements(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Achievement::class, 'user_achievements', 'user_id', 'achievement_id')
|
||||
@@ -298,6 +325,14 @@ class User extends Authenticatable
|
||||
|
||||
// ─── Meilisearch ──────────────────────────────────────────────────────────
|
||||
|
||||
/**
|
||||
* User indexing is handled explicitly through IndexUserJob so unrelated
|
||||
* model writes do not enqueue Scout sync jobs implicitly.
|
||||
*/
|
||||
protected static function bootSearchable(): void
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Only index active users (not soft-deleted, is_active = true).
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user