mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 20:44:19 +00:00
65 lines
1.5 KiB
PHP
65 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Classes\Notifications\InvoiceIssuedEmail;
|
|
use App\Classes\Notifications\ShipmentDepartureEmail;
|
|
use App\Http\Helpers\General;
|
|
use App\Models\Order;
|
|
use Carbon\Carbon;
|
|
|
|
use App\Models\Container;
|
|
use Illuminate\Console\Command;
|
|
|
|
class SendContainerDepartureEmailCommand extends Command
|
|
{
|
|
/**
|
|
* The name and signature of the console command.
|
|
*
|
|
* @var string
|
|
*/
|
|
|
|
protected $signature = 'command:sendContainerDepartureEmailCommand';
|
|
|
|
/**
|
|
* The console command description.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $description = 'Command description';
|
|
|
|
/**
|
|
* Create a new command instance.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
}
|
|
|
|
/**
|
|
* Execute the console command.
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public function handle()
|
|
{
|
|
$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));
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|