You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
monitor-doc/app/Mail/DocumentNotification.php

46 lines
1.1 KiB
PHTML

2 years ago
<?php
namespace App\Mail;
2 years ago
use App\Models\Category;
2 years ago
use App\Models\Document;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
class DocumentNotification extends Mailable
{
use Queueable, SerializesModels;
/**
* Create a new message instance.
*
* @return void
*/
2 years ago
public function __construct() {}
2 years ago
/**
* Build the message.
*
* @return $this
*/
public function build()
{
2 years ago
$docs = collect();
$categories = Category::all();
foreach($categories as $category) {
foreach($category->documents()->with(['variety'])->get() as $doc) {
2 years ago
if ($doc->is_close_due != 0) {
$docs->add($doc);
}
}
}
2 years ago
return $this->markdown('emails.document.notification', [
2 years ago
'documents' => $docs,
'dueDocuments' => Document::with(['variety'])->whereDate('due_date', '<=', now()->toDateString())->get()
2 years ago
]);
}
}