'datetime', 'accepted_at' => 'datetime', 'created_at' => 'datetime', ]; } public function creator(): BelongsTo { return $this->belongsTo(User::class, 'created_by')->withTrashed(); } public function players(): BelongsToMany { return $this->belongsToMany(Player::class, 'invitation_players'); } public function isValid(): bool { return $this->accepted_at === null && $this->expires_at->isFuture(); } public function isAccepted(): bool { return $this->accepted_at !== null; } public function scopeValid($query) { return $query->whereNull('accepted_at')->where('expires_at', '>', now()); } }