Minor display fixes, link to old site
This commit is contained in:
80
app/Classes/SSL.php
Normal file
80
app/Classes/SSL.php
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes;
|
||||
|
||||
class SSL
|
||||
{
|
||||
// Our CSR
|
||||
private $csr_pem = NULL;
|
||||
// Our Certificate
|
||||
private $crt = [];
|
||||
private $crt_pem = NULL;
|
||||
// Our Key
|
||||
private $key_pem = NULL;
|
||||
|
||||
/**
|
||||
* @param $key
|
||||
* @return null
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function __get($key)
|
||||
{
|
||||
switch($key)
|
||||
{
|
||||
case 'cn': return $this->cn();
|
||||
default:
|
||||
throw new \App\Exceptions\SSLUnknownAttribute($key);
|
||||
}
|
||||
}
|
||||
|
||||
private function cn()
|
||||
{
|
||||
$subject = array_get($this->crt,'subject');
|
||||
|
||||
if (! $subject AND $this->csr_pem) {
|
||||
$subject = openssl_csr_get_subject($this->csr_pem);
|
||||
}
|
||||
|
||||
return isset($subject['CN']) ? $subject['CN'] : NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add CSR
|
||||
*
|
||||
* @param $value
|
||||
* @return mixed
|
||||
*/
|
||||
public function csr($value)
|
||||
{
|
||||
$this->csr_pem = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add certificate
|
||||
*
|
||||
* @param $value
|
||||
* @return mixed
|
||||
*/
|
||||
public function crt($value)
|
||||
{
|
||||
$this->crt_pem = $value;
|
||||
$this->crt = openssl_x509_parse($this->crt);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the Key
|
||||
*
|
||||
* @param $value
|
||||
* @return mixed
|
||||
*/
|
||||
public function key($value)
|
||||
{
|
||||
$this->key_pem = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
9
app/Exceptions/SSLUnknownAttribute.php
Normal file
9
app/Exceptions/SSLUnknownAttribute.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
class SSLUnknownAttribute extends Exception
|
||||
{
|
||||
}
|
@@ -27,4 +27,18 @@ class UserHomeController extends Controller
|
||||
abort(500,'Unknown role: ',Auth::user()->role());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to redirect to the old site, when functions are not available in this one.
|
||||
*
|
||||
* @param $type
|
||||
* @param $action
|
||||
* @param $id
|
||||
* @return void
|
||||
* @deprecated @todo Remove once all functions added
|
||||
*/
|
||||
public function oldsite($type,$action,$id)
|
||||
{
|
||||
abort(307,sprintf('http://www.graytech.net.au/u/%s/%s/%s',$type,$action,$id));
|
||||
}
|
||||
}
|
@@ -12,12 +12,14 @@ class Payment extends Model
|
||||
|
||||
protected $appends = [
|
||||
'date_paid',
|
||||
'payment_id_url',
|
||||
'total',
|
||||
];
|
||||
|
||||
protected $visible = [
|
||||
'date_paid',
|
||||
'id',
|
||||
'payment_id_url',
|
||||
'total',
|
||||
];
|
||||
|
||||
@@ -36,6 +38,16 @@ class Payment extends Model
|
||||
return $this->date_payment->format('Y-m-d');
|
||||
}
|
||||
|
||||
public function getPaymentIdAttribute()
|
||||
{
|
||||
return sprintf('%02s-%04s+%05s',$this->site_id,$this->account_id,$this->id);
|
||||
}
|
||||
|
||||
public function getPaymentIdUrlAttribute()
|
||||
{
|
||||
return sprintf('<a href="/u/payment/view/%s">%s</a>',$this->id,$this->payment_id);
|
||||
}
|
||||
|
||||
public function getTotalAttribute()
|
||||
{
|
||||
return sprintf('%3.'.$this->currency()->rounding.'f',$this->total_amt);
|
||||
|
@@ -119,7 +119,7 @@ class Service extends Model
|
||||
|
||||
public function getServiceIdAttribute()
|
||||
{
|
||||
return sprintf('%02s-%05s',$this->site_id,$this->id);
|
||||
return sprintf('%02s-%04s.%05s',$this->site_id,$this->account_id,$this->id);
|
||||
}
|
||||
|
||||
public function getServiceIdUrlAttribute()
|
||||
|
@@ -2,17 +2,12 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Models\Service_Model as Model;
|
||||
|
||||
class ServiceAdsl extends Model
|
||||
{
|
||||
protected $table = 'ab_service__adsl';
|
||||
|
||||
public function service()
|
||||
{
|
||||
return $this->belongsTo(Service::class);
|
||||
}
|
||||
|
||||
public function getNameAttribute()
|
||||
{
|
||||
return $this->service_number;
|
||||
|
@@ -2,17 +2,12 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Models\Service_Model as Model;
|
||||
|
||||
class ServiceDomain extends Model
|
||||
{
|
||||
protected $table = 'ab_service__domain';
|
||||
|
||||
public function service()
|
||||
{
|
||||
return $this->belongsTo(Service::class);
|
||||
}
|
||||
|
||||
public function tld()
|
||||
{
|
||||
return $this->belongsTo(DomainTld::class,'domain_tld_id');
|
||||
|
@@ -2,17 +2,12 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Models\Service_Model as Model;
|
||||
|
||||
class ServiceHost extends Model
|
||||
{
|
||||
protected $table = 'ab_service__hosting';
|
||||
|
||||
public function service()
|
||||
{
|
||||
return $this->belongsTo(Service::class);
|
||||
}
|
||||
|
||||
public function getNameAttribute()
|
||||
{
|
||||
return sprintf('%s',$this->domain_name);
|
||||
|
@@ -2,25 +2,39 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Models\Service_Model as Model;
|
||||
use App\Classes\SSL;
|
||||
|
||||
class ServiceSsl extends Model
|
||||
{
|
||||
protected $table = 'ab_service__ssl';
|
||||
|
||||
public function service()
|
||||
{
|
||||
return $this->belongsTo(Service::class);
|
||||
}
|
||||
protected $_o = NULL;
|
||||
|
||||
public function tld()
|
||||
{
|
||||
return $this->belongsTo(DomainTld::class,'domain_tld_id');
|
||||
}
|
||||
|
||||
public function getSSLAttribute()
|
||||
{
|
||||
if (is_null($this->_o))
|
||||
{
|
||||
$this->_o = new SSL;
|
||||
|
||||
if ($this->cert)
|
||||
$this->_o->crt($this->cert);
|
||||
if ($this->csr)
|
||||
$this->_o->csr($this->csr);
|
||||
if ($this->pk)
|
||||
$this->_o->key($this->pk);
|
||||
|
||||
}
|
||||
|
||||
return $this->_o;
|
||||
}
|
||||
|
||||
public function getNameAttribute()
|
||||
{
|
||||
// @todo Merge in SSL functions from old site
|
||||
return 'SSL';
|
||||
return $this->ssl->cn;
|
||||
}
|
||||
}
|
@@ -2,17 +2,12 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Models\Service_Model as Model;
|
||||
|
||||
class ServiceVoip extends Model
|
||||
{
|
||||
protected $table = 'ab_service__voip';
|
||||
|
||||
public function service()
|
||||
{
|
||||
return $this->belongsTo(Service::class);
|
||||
}
|
||||
|
||||
public function getNameAttribute()
|
||||
{
|
||||
return $this->service_number;
|
||||
|
22
app/Models/Service_Model.php
Normal file
22
app/Models/Service_Model.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Abstract Base Model for Services
|
||||
*/
|
||||
abstract class Service_Model extends Model
|
||||
{
|
||||
public function service()
|
||||
{
|
||||
return $this->belongsTo(Service::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* The name of the server, that will appear on invoices/service displays
|
||||
* @return mixed
|
||||
*/
|
||||
abstract public function getNameAttribute();
|
||||
}
|
@@ -97,7 +97,7 @@ class User extends Authenticatable
|
||||
return $this->invoices
|
||||
->where('active',TRUE)
|
||||
->sortBy('id')
|
||||
->transform(function ($item) { if ($item->due) return $item; })
|
||||
->transform(function ($item) { if ($item->due > 0) return $item; })
|
||||
->reverse()
|
||||
->filter();
|
||||
}
|
||||
|
Reference in New Issue
Block a user