first_name} {$this->last_name}"); } public function getNameAttribute(): string { return $this->full_name; } protected function casts(): array { return [ 'date_of_birth' => 'date', 'is_blacklisted' => 'boolean', 'custom_fields' => 'array', ]; } public function event(): BelongsTo { return $this->belongsTo(Event::class); } public function crowdType(): BelongsTo { return $this->belongsTo(CrowdType::class); } public function company(): BelongsTo { return $this->belongsTo(Company::class); } public function user(): BelongsTo { return $this->belongsTo(User::class); } public function crowdLists(): BelongsToMany { return $this->belongsToMany(CrowdList::class, 'crowd_list_persons') ->using(\App\Models\Pivots\CrowdListPerson::class) ->withPivot('added_at', 'added_by_user_id'); } public function shiftAssignments(): HasMany { return $this->hasMany(ShiftAssignment::class); } public function volunteerAvailabilities(): HasMany { return $this->hasMany(VolunteerAvailability::class); } public function formSubmissions(): MorphMany { return $this->morphMany(\App\Models\FormBuilder\FormSubmission::class, 'subject'); } public function sectionPreferences(): HasMany { return $this->hasMany(PersonSectionPreference::class); } public function identityMatches(): HasMany { return $this->hasMany(PersonIdentityMatch::class); } public function pendingIdentityMatch(): HasOne { return $this->hasOne(PersonIdentityMatch::class) ->where('status', IdentityMatchStatus::PENDING) ->latest(); } public function confirmedIdentityMatch(): HasOne { return $this->hasOne(PersonIdentityMatch::class) ->where('status', IdentityMatchStatus::CONFIRMED) ->latest(); } public function scopeApproved(Builder $query): Builder { return $query->where('status', 'approved'); } public function scopePending(Builder $query): Builder { return $query->where('status', 'pending'); } public function scopeForCrowdType(Builder $query, string $type): Builder { return $query->whereHas('crowdType', fn (Builder $q) => $q->where('system_type', $type)); } }