Start work on updating services

This commit is contained in:
Deon George
2022-04-19 17:07:39 +10:00
parent ebf08ea414
commit 621a132e35
63 changed files with 1038 additions and 612 deletions

View File

@@ -5,19 +5,20 @@ namespace App\Models\Service;
use Illuminate\Support\Arr;
use Carbon\Carbon;
use App\Interfaces\ServiceItem;
use App\Models\Base\ServiceType;
use App\Traits\NextKey;
class SSL extends ServiceType implements ServiceItem
/**
* Class SSL (Service)
* Services that are provide an SSL Certificate
*/
class SSL extends ServiceType
{
use NextKey;
const RECORD_ID = 'service__ssl';
protected $table = 'service_ssl';
protected $table = 'ab_service__ssl';
protected $crt_parse = NULL;
protected $public_key = NULL;
protected $crt_parse = NULL;
/* STATIC */
public static function boot()
{
@@ -33,11 +34,27 @@ class SSL extends ServiceType implements ServiceItem
});
}
public function getValidToAttribute()
/* ABSTRACT */
/**
* Search for a record
*
* @param $query
* @param string $term
* @return mixed
*/
public function scopeSearch($query,string $term)
{
return $this->cert ? Carbon::createFromTimestamp($this->crt_parse->get('validTo_time_t')) : NULL;
// @todo
}
/* INTERFACES */
/**
* Return the Cert DN
*
* @return string
*/
public function getServiceDescriptionAttribute(): string
{
if ($this->cert)
@@ -58,11 +75,19 @@ class SSL extends ServiceType implements ServiceItem
}
}
public function getServiceExpireAttribute(): Carbon
/**
* Return the Certificate Expiry Date
*/
public function getServiceExpireAttribute(): ?Carbon
{
// TODO: Implement getServiceExpireAttribute() method.
return $this->cert ? Carbon::createFromTimestamp($this->crt_parse->get('validTo_time_t')) : NULL;
}
/**
* Return the Cert Name
*
* @return string
*/
public function getServiceNameAttribute(): string
{
return $this->cert
@@ -70,9 +95,24 @@ class SSL extends ServiceType implements ServiceItem
: Arr::get(openssl_csr_get_subject($this->csr),'CN','');
}
/**
* Certificates have no contract and can be cancelled anytime.
*
* @return bool
*/
public function inContract(): bool
{
// N/A
return FALSE;
}
/* METHODS */
/**
* @return Carbon|null
* @deprecated use getServiceExpireAttribute()
*/
public function getValidToAttribute()
{
abort(500,'use getServiceExpireAttribute');
}
}