mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-29 17:34:09 +00:00
45 lines
1.5 KiB
PHP
45 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Classes\Jobs\Commands\V2;
|
|
|
|
use Carbon\Carbon;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
use Illuminate\Queue\SerializesModels;
|
|
use App\Classes\Notifications\ShipmentDepartureEmail;
|
|
use App\Models\Order;
|
|
use App\Models\Container;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
class SendContainerDepartureEmailV2CommandJob implements ShouldQueue
|
|
{
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
|
|
|
public function handle()
|
|
{
|
|
Log::info(Carbon::now() . ': Start job - Send Container Departure Email.');
|
|
$start = new Carbon();
|
|
|
|
$containers = Container::whereHas('transports', function ($transport){
|
|
return $transport->whereDate('dispatch_date', '=', Carbon::today());
|
|
})->get();
|
|
|
|
foreach ($containers as $container){
|
|
foreach ($container->packingLists as $packingList){
|
|
if(!($packingList->owner instanceof Order)) continue;
|
|
$user = $packingList->owner->companyModule->employees()->first();
|
|
if(app()->environment(['production'])) {
|
|
$user->notify(new ShipmentDepartureEmail($user, $packingList));
|
|
}
|
|
}
|
|
}
|
|
|
|
$end = new Carbon();
|
|
$elapsedTime = $start->diff($end)->format('%H:%I:%S');
|
|
Log::info(Carbon::now() . ': End job - Send Container Departure Email. ElapsedTime: ' . $elapsedTime . '.');
|
|
}
|
|
}
|