Added characteristic approval function for testing purpose
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 11s
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 11s
This commit is contained in:
56
app/Jobs/SendApprover3MailJob.php
Normal file
56
app/Jobs/SendApprover3MailJob.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Mail\CharacteristicApprovalMail;
|
||||
use App\Models\CharacteristicApproverMaster;
|
||||
use App\Models\RequestCharacteristic;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Queue\Queueable;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class SendApprover3MailJob implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*/
|
||||
// public function __construct()
|
||||
// {
|
||||
// //
|
||||
// }
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*/
|
||||
public function __construct(public RequestCharacteristic $request) {}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
if (
|
||||
!is_null($this->request->approver_status1) ||
|
||||
!is_null($this->request->approver_status2) ||
|
||||
!is_null($this->request->approver_status3)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->request->approver3_mail_sent) return;
|
||||
|
||||
$approver = CharacteristicApproverMaster::where('plant_id', $this->request->plant_id)
|
||||
->where('machine_id', $this->request->machine_id)
|
||||
->first();
|
||||
|
||||
if (! $approver || ! $approver->mail3) return;
|
||||
|
||||
Mail::to($approver->mail3)
|
||||
->queue(new CharacteristicApprovalMail(
|
||||
$this->request,
|
||||
$approver->name3,
|
||||
3
|
||||
));
|
||||
|
||||
$this->request->update(['approver3_mail_sent' => 1]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user