-
app/Notifications/JobApplicationReceivedNotification.php
Open in GitHubuse App\Models\JobApplication; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Notification; class JobApplicationReceivedNotification extends Notification implements ShouldQueue { use Queueable; public $application; public function __construct(JobApplication $application) { $this->application = $application; } public function via($notifiable) { return ["mail"]; } public function toMail($notifiable) { return (new MailMessage()) ->subject(__("New Job Application")) ->line(__("Hey :name,", ["name" => $notifiable->name])) ->line( __("You have just received a new job application for :job", [ "job" => $this->application->job->job_title, ]) ) ->line( __("Applicant name: :applicantName", [ "applicantName" => $this->application->name, ]) ) ->line( __("Applicant phone: :applicantPhone", [ "applicantPhone" => $this->application->phone, ]) ) ->line( __("Applicant email: :applicantEmail", [ "applicantEmail" => $this->application->email, ]) ) ->action(__("Go to dashboard"), url(route("dashboard"))) ->line(__("Regards")); } // ... }
-
app/Listeners/JobApplicationListener.php
Open in GitHubuse App\Events\JobApplicationReceivedEvent; use App\Notifications\JobApplicationReceivedNotification; class JobApplicationListener { // ... public function handle(JobApplicationReceivedEvent $event) { $user = $event->application->job->user; $user->notify(new JobApplicationReceivedNotification($event->application)); } }