php class ProcessLetterApproval implements ShouldQueue
{
protected $letter;
protected $userId;
public function __construct(Letter $letter, $userId)
{
$this->letter = $letter;
$this->userId = $userId;
}
public function handle()
{
$this->letter->update([
'status' => 'approved',
]);
$pdf = PDF::loadView('letter-template', ['letter' => $this->letter]);
$fileName = 'letter_'.$this->letter->id.'_'.time().'.pdf';
Storage::put('public/letters/'.$fileName, $pdf->output());
$this->letter->update(['file_path' => 'letters/'.$fileName]);
}
protected function sendNotification()
{
$recipient = User::find($this->letter->user_id);
Notification::make()
->body("Your {$this->letter->template->name} Letter Request has been changed")
->actions([
Action::make('index')
->url(LetterResource::getUrl('index',
['record' => $this->letter])),
])
->sendToDatabase($recipient);
}
}
php class ProcessLetterApproval implements ShouldQueue
{
protected $letter;
protected $userId;
public function __construct(Letter $letter, $userId)
{
$this->letter = $letter;
$this->userId = $userId;
}
public function handle()
{
$this->letter->update([
'status' => 'approved',
]);
$pdf = PDF::loadView('letter-template', ['letter' => $this->letter]);
$fileName = 'letter_'.$this->letter->id.'_'.time().'.pdf';
Storage::put('public/letters/'.$fileName, $pdf->output());
$this->letter->update(['file_path' => 'letters/'.$fileName]);
}
protected function sendNotification()
{
$recipient = User::find($this->letter->user_id);
Notification::make()
->body("Your {$this->letter->template->name} Letter Request has been changed")
->actions([
Action::make('index')
->url(LetterResource::getUrl('index',
['record' => $this->letter])),
])
->sendToDatabase($recipient);
}
}