Files
jandl-taskmanager-app/be/app/Mail/SubTaskEdited.php
T
2025-12-16 17:25:19 +01:00

72 lines
1.6 KiB
PHP

<?php
namespace App\Mail;
use App\Models\SubTask;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;
class SubTaskEdited extends Mailable
{
use Queueable, SerializesModels;
public $subtask;
public $difference;
public $creator;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct(SubTask $subtask, array $difference)
{
$creator = \App\Models\User::find($subtask->created_by);
$this->creator = ($creator) ? $creator->firstname . ' ' . $creator->lastname : '';
$this->subtask = $subtask;
$this->difference = $difference;
}
/**
* Get the message envelope.
*
* @return \Illuminate\Mail\Mailables\Envelope
*/
public function envelope()
{
$projectCode = $this->subtask->mastertask?->project?->code ?? 'N/A';
$title = $this->subtask->title ?: $this->subtask->mastertask?->title ?? '';
return new Envelope(
subject: 'Bol editovaný Sub Task ' . $projectCode . ' - ' . $title,
);
}
/**
* Get the message content definition.
*
* @return \Illuminate\Mail\Mailables\Content
*/
public function content()
{
return new Content(
view: 'emails.task.sub_task_edited',
);
}
/**
* Get the attachments for the message.
*
* @return array
*/
public function attachments()
{
return [];
}
}