Enabled console invoice generation
This commit is contained in:
@@ -2,6 +2,9 @@
|
||||
|
||||
namespace App\Models\Service;
|
||||
|
||||
use Illuminate\Support\Arr;
|
||||
use Carbon\Carbon;
|
||||
|
||||
use App\Interfaces\ServiceItem;
|
||||
use App\Models\Base\ServiceType;
|
||||
use App\Traits\NextKey;
|
||||
@@ -13,32 +16,53 @@ class SSL extends ServiceType implements ServiceItem
|
||||
|
||||
protected $table = 'ab_service__ssl';
|
||||
|
||||
protected $_o = NULL;
|
||||
protected $crt_parse = NULL;
|
||||
protected $public_key = NULL;
|
||||
|
||||
public function getSSLAttribute()
|
||||
public static function boot()
|
||||
{
|
||||
if (is_null($this->_o)) {
|
||||
$this->_o = new \App\Classes\SSL;
|
||||
parent::boot();
|
||||
|
||||
if ($this->cert)
|
||||
$this->_o->crt($this->cert);
|
||||
if ($this->csr)
|
||||
$this->_o->csr($this->csr);
|
||||
if ($this->pk)
|
||||
$this->_o->key($this->pk);
|
||||
}
|
||||
static::retrieved(function($model) {
|
||||
if ($model->cert);
|
||||
$model->crt_parse = collect(openssl_x509_parse($model->cert));
|
||||
|
||||
return $this->_o;
|
||||
if ($model->csr) {
|
||||
$model->public_key = collect(openssl_pkey_get_details(openssl_csr_get_public_key($model->csr)));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function getValidToAttribute()
|
||||
{
|
||||
return $this->cert ? Carbon::createFromTimestamp($this->crt_parse->get('validTo_time_t')) : NULL;
|
||||
}
|
||||
|
||||
public function getServiceDescriptionAttribute(): string
|
||||
{
|
||||
return $this->ssl->dn;
|
||||
if ($this->cert)
|
||||
return Arr::get($this->crt_parse,'name');
|
||||
|
||||
else {
|
||||
$dn = '';
|
||||
$dna = openssl_csr_get_subject($this->csr);
|
||||
|
||||
foreach ($dna as $k=>$v) {
|
||||
if ($dn)
|
||||
$dn .= ',';
|
||||
|
||||
$dn .= sprintf('%s=%s',$k,$v);
|
||||
}
|
||||
|
||||
return $dn;
|
||||
}
|
||||
}
|
||||
|
||||
public function getServiceNameAttribute(): string
|
||||
{
|
||||
return $this->ssl->cn;
|
||||
return $this->cert
|
||||
? Arr::get($this->crt_parse,'subject.CN')
|
||||
: Arr::get(openssl_csr_get_subject($this->csr),'CN');
|
||||
}
|
||||
|
||||
public function inContract(): bool
|
||||
|
Reference in New Issue
Block a user