Update source into github
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\VirtualMachine\Create;
|
||||
|
||||
use App\Events\Create_VirtualMachine_Success;
|
||||
use App\Http\Facade\SignRSA;
|
||||
use App\Http\Facade\HelperFacade as Helper;
|
||||
use App\Http\Services\Telegram;
|
||||
use App\Jobs\Mail\SendInformationVirtualMachine;
|
||||
use App\Models\Setting;
|
||||
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;
|
||||
|
||||
class ConfigDatabase implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
protected $data;
|
||||
protected $info;
|
||||
protected $telegram;
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($data,$info)
|
||||
{
|
||||
$this->data = $data;
|
||||
$this->info = $info;
|
||||
$this->telegram = new Telegram();
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->data->update([
|
||||
'name' => $this->data->ipaddress->ip . '_' . $this->data->cannotustomer->firstname,
|
||||
'port' => $this->info['port'],
|
||||
'user' => $this->info['user'],
|
||||
'password' => SignRSA::EncryptFunc($this->info['password']),
|
||||
'status' => 1
|
||||
]);
|
||||
|
||||
$this->data->ipAddress->update([
|
||||
'vm_name' => $this->data->IpAddress->ip . '_' . $this->data->Customer->firstname,
|
||||
'status' => 1
|
||||
]);
|
||||
|
||||
$setting = Setting::where('key', 'setting')->first();
|
||||
|
||||
$data = [
|
||||
'company_name' => json_decode($setting->value)->company,
|
||||
'company_logo' => json_decode($setting->value)->logo,
|
||||
'client_name' => $this->data->Customer->firstname . " " . $this->data->Customer->lastname,
|
||||
'product_name' => $this->data->GetInvoiceItem()->GetItemProduct()->name,
|
||||
'product_billing' => Helper::billing_cycle($this->data->GetInvoiceItem()->billing),
|
||||
'product_price' => number_format($this->data->GetInvoiceItem()->amount, 0, ',', '.'),
|
||||
'service_host' => $this->data->IpAddress->ip,
|
||||
'service_username' => $this->info['user'],
|
||||
'service_port' => $this->info['port'],
|
||||
'service_password' => $this->info['password'],
|
||||
'os_name' => $this->data->Os->OsGroup->name . " " . $this->data->Os->version,
|
||||
'service_due_exp' => Carbon::parse($this->data->next_due_date)->format('d/m/Y')
|
||||
];
|
||||
|
||||
$mail = new SendInformationVirtualMachine($data, $this->data->Customer);
|
||||
|
||||
dispatch($mail)->delay(now()->addSeconds(5));
|
||||
|
||||
Event(new Create_VirtualMachine_Success("Máy chủ của bạn đã được khởi tạo thành công!",
|
||||
$this->data->customer->id));
|
||||
|
||||
$this->telegram->SendInformation($this->data, $this->info['user'], $this->info['password'], $this->info['port']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user