Files
wticreatorstudio/Modules/WTIJobBoard/Console/JobOrderDueReminder.php
T
Leonard Biano e0e8775d96 WTIJobBoard Module Update
Customer company info changes
2024-07-04 19:33:48 +08:00

62 lines
1.9 KiB
PHP

<?php
namespace Modules\WTIJobBoard\Console;
use Illuminate\Support\Str;
use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
use Modules\WTIJobBoard\Entities\JobRequest;
use Illuminate\Support\Facades\Log;
use App\Traits\SendMail;
class JobOrderDueReminder extends Command
{
use SendMail;
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'command:job-order-due';
/**
* The console command description.
*
* @var string
*/
protected $description = "Notify admin and client relations for there Job Order Due";
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
\Modules\WTIJobBoard\Entities\JobRequest::with('track')->whereHas('category', function($query) {
$query->where('will_be_shipped', 1);
})->whereHas('tracks', function($query) {
$query->where('status_id', 4)->where('created_at', '<=', \Carbon\Carbon::now()->subDays(28)->toDateTimeString())->where('created_at', '>=', \Carbon\Carbon::now()->subDays(60)->toDateTimeString());
})->where('status','publish')->where('job_status','In Progress')->orderBy('id')->chunk(10, function ($job_requests) {
foreach ($job_requests as $key => $job_request) {
$this->sendJobRequestReminder('Job Order Due',$job_request->creator, $job_request->asin, $job_request->client->company->brand_name ?? null);
Log::info('Successfully sent Job Order Due Email for asin:'.$job_request->asin);
}
});
}
}