Update source into github
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Jobs\Hosting\HostingJobs;
|
||||
use App\Models\Customer;
|
||||
use App\Models\ModuleHosting;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class ServiceHosting extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'hosting:expiry';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Check hết hạn dịch vụ hosting';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$jobs = [];
|
||||
$allUser = Customer::get();
|
||||
|
||||
foreach ($allUser as $item)
|
||||
{
|
||||
$Hosting = ModuleHosting::with('Server')->where('customer_id',$item->id)->first();
|
||||
if ($Hosting)
|
||||
{
|
||||
$ServiceExpiry = Carbon::now()->diffInDays(Carbon::parse($Hosting->next_due_date),false);
|
||||
if ($ServiceExpiry <= 0)
|
||||
{
|
||||
$jobs[] = new HostingJobs($item->id,'Suspend');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
foreach ($jobs as $_job)
|
||||
{
|
||||
dispatch($_job)->delay(now()->addSeconds(10));
|
||||
}
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user