Jelajahi Sumber

Add AdminMessageResponse

Daniel Supernault 9 bulan lalu
induk
melakukan
1173e63a45

+ 71 - 0
app/Mail/AdminMessageResponse.php

@@ -0,0 +1,71 @@
+<?php
+
+namespace App\Mail;
+
+use App\Contact;
+use Illuminate\Bus\Queueable;
+use Illuminate\Mail\Mailable;
+use Illuminate\Mail\Mailables\Content;
+use Illuminate\Mail\Mailables\Envelope;
+use Illuminate\Mail\Mailables\Headers;
+use Illuminate\Queue\SerializesModels;
+
+class AdminMessageResponse extends Mailable
+{
+    use Queueable, SerializesModels;
+
+    /**
+     * Create a new message instance.
+     */
+    public function __construct(
+        public Contact $contact,
+    ) {}
+
+    /**
+     * Get the message headers.
+     */
+    public function headers(): Headers
+    {
+        $mid = $this->contact->getMessageId();
+
+        return new Headers(
+            messageId: $mid,
+            text: [
+                'X-Entity-Ref-ID' => $mid,
+            ],
+        );
+    }
+
+    /**
+     * Get the message envelope.
+     */
+    public function envelope(): Envelope
+    {
+        return new Envelope(
+            subject: ucfirst(strtolower(config('pixelfed.domain.app'))).' Contact Form Response [Ticket #'.$this->contact->id.']',
+        );
+    }
+
+    /**
+     * Get the message content definition.
+     */
+    public function content(): Content
+    {
+        return new Content(
+            markdown: 'emails.contact.admin-response',
+            with: [
+                'url' => $this->contact->userResponseUrl(),
+            ],
+        );
+    }
+
+    /**
+     * Get the attachments for the message.
+     *
+     * @return array<int, \Illuminate\Mail\Mailables\Attachment>
+     */
+    public function attachments(): array
+    {
+        return [];
+    }
+}

+ 24 - 0
resources/views/emails/contact/admin-response.blade.php

@@ -0,0 +1,24 @@
+<x-mail::message>
+Hello **&commat;{{$contact->user->username}}**,
+
+You contacted the admin team of {{config('pixelfed.domain.app')}} with the following inquiry:
+
+<x-mail::panel>
+<i>{{str_limit($contact->message, 80)}}</i>
+</x-mail::panel>
+
+<x-mail::button :url="$url" color="primary">
+    View Admin Response
+</x-mail::button>
+
+<small>
+or copy and paste the following url: <a href="{{$url}}">{{$url}}</a>
+</small>
+<br>
+<br>
+<br>
+<small>
+Thanks,<br>
+The {{ ucfirst(config('pixelfed.domain.app')) }} Admin Team
+</small>
+</x-mail::message>