diff --git a/app/Letter/Letter.php b/app/Letter/Letter.php index 88b6afa0..854913b7 100644 --- a/app/Letter/Letter.php +++ b/app/Letter/Letter.php @@ -105,4 +105,18 @@ abstract class Letter extends Document } } } + + /** + * @return view-string + */ + public function mailView(): string + { + $view = 'mail.payment.'.Str::snake(class_basename($this)); + + if (!view()->exists($view)) { + throw new Exception('Mail view '.$view.' existiert nicht.'); + } + + return $view; + } } diff --git a/app/Payment/PaymentMail.php b/app/Payment/PaymentMail.php index 45a6fefd..2fad5612 100644 --- a/app/Payment/PaymentMail.php +++ b/app/Payment/PaymentMail.php @@ -6,7 +6,6 @@ use App\Letter\Letter; use Illuminate\Bus\Queueable; use Illuminate\Mail\Mailable; use Illuminate\Queue\SerializesModels; -use Illuminate\Support\Str; class PaymentMail extends Mailable { @@ -36,9 +35,7 @@ class PaymentMail extends Mailable */ public function build() { - $template = Str::snake(class_basename($this->letter)); - - return $this->markdown('mail.payment.'.$template) + return $this->markdown($this->letter->mailView()) ->attach($this->filename) ->replyTo('kasse@stamm-silva.de') ->subject($this->letter->getSubject().' | DPSG Stamm Silva'); diff --git a/phpstan.neon b/phpstan.neon index 1e1ad7f7..0556c7b8 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -10,7 +10,7 @@ parameters: - packages/tex/src # The level 8 is the highest level - level: 6 + level: 7 ignoreErrors: -