|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace App\Mail; |
| 4 | + |
| 5 | +use App\Models\Report; |
| 6 | +use App\Services\AccountService; |
| 7 | +use App\Services\ReportService; |
| 8 | +use Illuminate\Bus\Queueable; |
| 9 | +use Illuminate\Mail\Mailable; |
| 10 | +use Illuminate\Mail\Mailables\Content; |
| 11 | +use Illuminate\Mail\Mailables\Envelope; |
| 12 | +use Illuminate\Queue\SerializesModels; |
| 13 | + |
| 14 | +class AdminReport extends Mailable |
| 15 | +{ |
| 16 | + use Queueable, SerializesModels; |
| 17 | + |
| 18 | + public $report; |
| 19 | + |
| 20 | + /** |
| 21 | + * Create a new message instance. |
| 22 | + */ |
| 23 | + public function __construct(Report $report) |
| 24 | + { |
| 25 | + $this->report = $report; |
| 26 | + } |
| 27 | + |
| 28 | + /** |
| 29 | + * Get the message envelope. |
| 30 | + */ |
| 31 | + public function envelope(): Envelope |
| 32 | + { |
| 33 | + return new Envelope( |
| 34 | + subject: 'Report #'.$this->report->id, |
| 35 | + ); |
| 36 | + } |
| 37 | + |
| 38 | + /** |
| 39 | + * Get the message content definition. |
| 40 | + */ |
| 41 | + public function content(): Content |
| 42 | + { |
| 43 | + $reporter = AccountService::compact($this->report->reporter_profile_id); |
| 44 | + $reporterUsername = data_get($reporter, 'username', 'a user'); |
| 45 | + $reportedEntityType = $this->report->reportEntityType(); |
| 46 | + |
| 47 | + return new Content( |
| 48 | + markdown: 'emails.admin.report', |
| 49 | + with: [ |
| 50 | + 'id' => $this->report->id, |
| 51 | + 'entity' => $reportedEntityType, |
| 52 | + 'reporterUsername' => $reporterUsername, |
| 53 | + 'reportType' => ReportService::getById($this->report->report_type), |
| 54 | + 'url' => $this->report->adminUrl(), |
| 55 | + ] |
| 56 | + ); |
| 57 | + } |
| 58 | + |
| 59 | + /** |
| 60 | + * Get the attachments for the message. |
| 61 | + * |
| 62 | + * @return array<int, \Illuminate\Mail\Mailables\Attachment> |
| 63 | + */ |
| 64 | + public function attachments(): array |
| 65 | + { |
| 66 | + return []; |
| 67 | + } |
| 68 | +} |
0 commit comments