Initial commit
This commit is contained in:
38
app/Mail/Forms/FormCreationConfirmationMail.php
Normal file
38
app/Mail/Forms/FormCreationConfirmationMail.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mail\Forms;
|
||||
|
||||
use App\Mail\OpenFormMail;
|
||||
use App\Models\Forms\Form;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class FormCreationConfirmationMail extends OpenFormMail implements ShouldQueue
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(public Form $form)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the message.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
return $this
|
||||
->markdown('mail.form.created',[
|
||||
'form' => $this->form,
|
||||
])->subject('Your form was created!');
|
||||
}
|
||||
}
|
||||
53
app/Mail/Forms/SubmissionConfirmationMail.php
Normal file
53
app/Mail/Forms/SubmissionConfirmationMail.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mail\Forms;
|
||||
|
||||
use App\Events\Forms\FormSubmitted;
|
||||
use App\Mail\OpenFormMail;
|
||||
use App\Service\Forms\FormSubmissionFormatter;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class SubmissionConfirmationMail extends OpenFormMail implements ShouldQueue
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(private FormSubmitted $event)
|
||||
{}
|
||||
|
||||
/**
|
||||
* Build the message.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
$form = $this->event->form;
|
||||
|
||||
$formatter = (new FormSubmissionFormatter($form, $this->event->data))
|
||||
->createLinks()
|
||||
->outputStringsOnly();
|
||||
|
||||
return $this
|
||||
->replyTo($form->creator->email)
|
||||
->from($this->getFromEmail(), $form->notification_sender)
|
||||
->subject($form->notification_subject)
|
||||
->markdown('mail.form.confirmation-submission-notification',[
|
||||
'fields' => $formatter->getFieldsWithValue(),
|
||||
'form' => $form,
|
||||
]);
|
||||
}
|
||||
|
||||
private function getFromEmail()
|
||||
{
|
||||
$originalFromAddress = Str::of(config('mail.from.address'))->explode('@');
|
||||
return $originalFromAddress->first(). '+' . time() . '@' . $originalFromAddress->last();
|
||||
}
|
||||
}
|
||||
13
app/Mail/OpenFormMail.php
Normal file
13
app/Mail/OpenFormMail.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
abstract class OpenFormMail extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
}
|
||||
Reference in New Issue
Block a user