-
app/Jobs/Emails/GoodbyeEmailJob.php
Open in GitHubuse App\Mail\UserDeleted; use App\User; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; use Illuminate\Support\Facades\Mail; class GoodbyeEmailJob implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; public $email; public $userId; public $language; public $tries = 3; public function __construct(User $user, string $language = 'en') { $this->userId = $user->id; $this->email = $user->email; $this->language = $language; } public function handle() { Mail::to('hello@kanka.io') ->locale($this->language) ->send( new UserDeleted($this->userId, $this->email) ); } }
-
app/Mail/UserDeleted.php
Open in GitHubuse App\User; use Illuminate\Bus\Queueable; use Illuminate\Mail\Mailable; use Illuminate\Queue\SerializesModels; use Illuminate\Contracts\Queue\ShouldQueue; class UserDeleted extends Mailable { use Queueable, SerializesModels; public $email; public $id; public function __construct(int $userId, string $email) { $this->id = $userId; $this->email = $email; } public function build() { return $this ->from(['address' => 'no-reply@kanka.io', 'name' => 'Kanko Support']) ->subject('Account #' . $this->id . ' deleted - ' . $this->email) ->view('emails.goodbye'); } }
-
resources/views/emails/goodbye.blade.php
Open in GitHubUser #{{ $id }} with email {{ $email }} deleted their account.