Add remember via email
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
60ddedbe8a
commit
14a478785e
|
@ -7,6 +7,7 @@ use Illuminate\Bus\Queueable;
|
|||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class PaymentMail extends Mailable
|
||||
{
|
||||
|
@ -33,9 +34,10 @@ class PaymentMail extends Mailable
|
|||
*/
|
||||
public function build()
|
||||
{
|
||||
return $this->markdown('mail.payment.payment')
|
||||
$template = Str::snake(class_basename($this->repo));
|
||||
return $this->markdown('mail.payment.'.$template)
|
||||
->attach($this->filename)
|
||||
->replyTo('kasse@stamm-silva.de')
|
||||
->subject('Jahresrechnung | DPSG Stamm Silva');
|
||||
->subject($this->repo->getMailSubject().' | DPSG Stamm Silva');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace App\Payment;
|
|||
use App\Pdf\BillType;
|
||||
use App\Pdf\PdfGenerator;
|
||||
use App\Pdf\PdfRepositoryFactory;
|
||||
use App\Pdf\RememberType;
|
||||
use Illuminate\Console\Command;
|
||||
use Mail;
|
||||
|
||||
|
@ -40,6 +41,12 @@ class PaymentSendCommand extends Command
|
|||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->sendBills();
|
||||
$this->sendRemembers();
|
||||
}
|
||||
|
||||
private function sendBills(): void
|
||||
{
|
||||
$repos = app(PdfRepositoryFactory::class)->repoCollection(BillType::class, 'E-Mail');
|
||||
|
||||
|
@ -52,8 +59,21 @@ class PaymentSendCommand extends Command
|
|||
Mail::to($to)->send(new PaymentMail($repo, $generator->getCompiledFilename()));
|
||||
app(PdfRepositoryFactory::class)->afterSingle($repo);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
private function sendRemembers(): void
|
||||
{
|
||||
$repos = app(PdfRepositoryFactory::class)->repoCollection(RememberType::class, 'E-Mail');
|
||||
|
||||
foreach ($repos as $repo) {
|
||||
$generator = app(PdfGenerator::class)->setRepository($repo)->render();
|
||||
$to = (object) [
|
||||
'email' => $repo->getEmail($repo->pages->first()),
|
||||
'name' => $repo->getFamilyName($repo->pages->first()),
|
||||
];
|
||||
Mail::to($to)->send(new PaymentMail($repo, $generator->getCompiledFilename()));
|
||||
app(PdfRepositoryFactory::class)->afterSingle($repo);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -120,4 +120,9 @@ class BillType extends Repository implements PdfRepository
|
|||
$payment->update(['status_id' => 2]);
|
||||
}
|
||||
|
||||
public function getMailSubject(): string
|
||||
{
|
||||
return 'Jahresrechnung';
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -48,4 +48,6 @@ interface PdfRepository
|
|||
|
||||
public function afterSingle(Payment $payment): void;
|
||||
|
||||
public function getMailSubject(): string;
|
||||
|
||||
}
|
||||
|
|
|
@ -97,7 +97,7 @@ class RememberType extends Repository implements PdfRepository
|
|||
return "Mitgliedsbeitrag für {$this->getFamilyName($page)}";
|
||||
}
|
||||
|
||||
public function allLabel(): string
|
||||
public function allLabel(): string
|
||||
{
|
||||
return 'Erinnerungen versenden';
|
||||
}
|
||||
|
@ -120,4 +120,9 @@ class RememberType extends Repository implements PdfRepository
|
|||
$payment->update(['last_remembered_at' => now()]);
|
||||
}
|
||||
|
||||
public function getMailSubject(): string
|
||||
{
|
||||
return 'Zahlungserinnerung';
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
@component('mail::message')
|
||||
# Liebe Familie {{ $repo->getFamilyName($repo->pages->first()) }},
|
||||
|
||||
Hiermit möchten wir euch an die noch ausstehenden Mitgliedsbeiträge des Stammes Silva für das laufende Jahr erinnern. Bitte begleicht diese bis zum angegebenen Datum.
|
||||
|
||||
@component('mail::subcopy')
|
||||
|
||||
Herzliche Grüße und gut Pfad
|
||||
|
||||
Der Stammesvorstand
|
||||
@endcomponent
|
||||
|
||||
@endcomponent
|
Loading…
Reference in New Issue