Update source into github
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Jobs\Mail\ExpiryMail;
|
||||
use App\Models\Customer;
|
||||
use App\Models\ModuleVmware;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class VPSMail extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'vps:mail';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$jobs = [];
|
||||
$allUser = Customer::get();
|
||||
|
||||
foreach ($allUser as $item)
|
||||
{
|
||||
$vps = ModuleVmware::where('customer_id',$item->id)->first();
|
||||
if ($vps)
|
||||
{
|
||||
$ServiceExpiry = Carbon::now()->diffInDays(Carbon::parse($vps->next_due_date),false);
|
||||
if ($ServiceExpiry <= 5 && $ServiceExpiry > 0)
|
||||
{
|
||||
$jobs[] = new ExpiryMail($vps->id,5,4);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
foreach ($jobs as $_job)
|
||||
{
|
||||
dispatch($_job)->delay(now()->addSeconds(10));
|
||||
}
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user