*/ protected $casts = [ 'reliability_score' => 'decimal:2', 'is_ambassador' => 'bool', 'settings' => 'array', ]; public function user(): BelongsTo { return $this->belongsTo(User::class); } /** * Computed: the most recent submitted_at across submissions whose subject * is this user (non-test only). Null when user has no submissions. */ protected function lastSubmittedAt(): Attribute { return Attribute::make( get: fn () => FormSubmission::query() ->where('subject_type', 'user') ->where('subject_id', $this->user_id) ->where('status', FormSubmissionStatus::SUBMITTED) ->where('is_test', false) ->max('submitted_at'), ); } }