-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move send message to single attendee controller to use a mail job lik…
…e the other emails, this will also allow it to get the organizer logo in the email
- Loading branch information
Showing
3 changed files
with
122 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
|
||
namespace App\Jobs; | ||
|
||
use App\Mail\SendMessageToAttendeeMail; | ||
use App\Models\Attendee; | ||
use App\Models\Event; | ||
use Carbon\Carbon; | ||
use Illuminate\Bus\Queueable; | ||
use Illuminate\Contracts\Queue\ShouldQueue; | ||
use Illuminate\Foundation\Bus\Dispatchable; | ||
use Illuminate\Queue\InteractsWithQueue; | ||
use Illuminate\Queue\SerializesModels; | ||
use Config; | ||
use Mail; | ||
|
||
class SendMessageToAttendeeJob implements ShouldQueue | ||
{ | ||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; | ||
|
||
public $subject; | ||
public $content; | ||
public $event; | ||
public $attendee; | ||
public $send_copy; | ||
|
||
/** | ||
* Create a new job instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct($subject, $content, Event $event, Attendee $attendee, $send_copy) | ||
{ | ||
$this->subject = $subject; | ||
$this->content = $content; | ||
$this->event = $event; | ||
$this->attendee = $attendee; | ||
$this->send_copy = $send_copy; | ||
} | ||
|
||
/** | ||
* Execute the job. | ||
* | ||
* @return void | ||
*/ | ||
public function handle() | ||
{ | ||
$mail = new SendMessageToAttendeeMail( | ||
$this->subject, | ||
$this->content, | ||
$this->event, | ||
$this->attendee | ||
); | ||
Mail::to($this->attendee->email, $this->attendee->full_name) | ||
->locale(Config::get('app.locale')) | ||
->send($mail); | ||
|
||
if ($this->send_copy == '1') { | ||
$mail->subject = $mail->subject . trans("Email.organiser_copy"); | ||
Mail::to($this->event->organiser->email, $this->event->organiser->name) | ||
->locale(Config::get('app.locale')) | ||
->send($mail); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
namespace App\Mail; | ||
|
||
use App\Models\Attendee; | ||
use App\Models\Event; | ||
use Illuminate\Bus\Queueable; | ||
use Illuminate\Contracts\Queue\ShouldQueue; | ||
use Illuminate\Mail\Mailable; | ||
use Illuminate\Queue\SerializesModels; | ||
|
||
class SendMessageToAttendeeMail extends Mailable | ||
{ | ||
use Queueable, SerializesModels; | ||
|
||
public $subject; | ||
public $content; | ||
public $event; | ||
public $attendee; | ||
public $email_logo; | ||
|
||
/** | ||
* Create a new message instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct($subject, $content, Event $event, Attendee $attendee) | ||
{ | ||
$this->subject = $subject; | ||
$this->content = $content; | ||
$this->event = $event; | ||
$this->attendee = $attendee; | ||
$this->email_logo = $event->organiser->full_logo_path; | ||
} | ||
|
||
/** | ||
* Build the message. | ||
* | ||
* @return $this | ||
*/ | ||
public function build() | ||
{ | ||
return $this->subject($this->subject) | ||
->from(config('attendize.outgoing_email_noreply'), $this->event->organiser->name) | ||
->replyTo($this->event->organiser->email, $this->event->organiser->name) | ||
->view('Emails.MessageToAttendees'); | ||
} | ||
} |