*/ public static function card(JobPosting $posting): array { return [ 'id' => $posting->id, 'title' => $posting->title, 'department' => $posting->department, 'location' => $posting->location, 'employment' => $posting->employment, 'employment_label' => JobPosting::EMPLOYMENT[$posting->employment] ?? null, 'summary' => $posting->summary(), 'deadline' => $posting->deadline?->toDateString(), 'published_at' => $posting->published_at?->toIso8601String(), 'status' => $posting->status(), 'url' => route('jobs.show', $posting), ]; } /** * @return array */ public static function detail(JobPosting $posting, User $viewer): array { $contact = $posting->contact?->is_active ? $posting->contact : null; return [ ...self::card($posting), 'hours' => $posting->hours, 'contract' => $posting->contract, 'contract_label' => JobPosting::CONTRACT[$posting->contract] ?? null, 'contract_note' => $posting->contract_note, 'pay_grade' => $posting->pay_grade, 'start' => $posting->start, 'description' => $posting->description, 'pdf' => $posting->pdf_path ? ['name' => $posting->pdf_name, 'url' => route('jobs.pdf', $posting)] : null, 'apply_mode' => $posting->apply_mode, 'apply_url' => $posting->apply_mode === 'link' ? $posting->apply_url : null, 'apply_email' => $posting->apply_mode === 'email' ? $posting->apply_email : null, 'contact' => $contact ? [ 'id' => $contact->id, 'name' => $contact->name, 'initials' => $contact->initials, 'job_title' => $contact->job_title, 'email' => $contact->email, 'phone' => $contact->phone, 'avatar_url' => $contact->avatarUrl(96), ] : null, ]; } /** * @return array */ public static function application(JobApplication $application, bool $withPerson = false): array { return [ 'id' => $application->id, 'status' => $application->status, 'status_label' => JobApplication::STATUSES[$application->status] ?? $application->status, 'message' => $application->message, 'file' => $application->file_path ? ['name' => $application->file_name, 'url' => route('jobs.applications.file', $application)] : null, 'created_at' => $application->created_at?->toIso8601String(), 'updated_at' => $application->updated_at?->toIso8601String(), 'note' => $withPerson ? $application->note : null, 'person' => $withPerson && $application->user ? [ 'id' => $application->user->id, 'name' => $application->user->name, 'initials' => $application->user->initials, 'job_title' => $application->user->job_title, 'department' => $application->user->department, 'email' => $application->user->email, 'avatar_url' => $application->user->avatarUrl(96), ] : null, ]; } }