Optimise users home page
This commit is contained in:
@@ -12,17 +12,30 @@ use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Leenooks\Carbon;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
|
||||
use Leenooks\Carbon;
|
||||
use App\Interfaces\IDs;
|
||||
use App\Traits\NextKey;
|
||||
|
||||
class Service extends Model
|
||||
/**
|
||||
* Class Service
|
||||
* Services that belong to an account
|
||||
*
|
||||
* Attributes for services:
|
||||
* + name_short : Service Product short name, eg: phone number, domain name, certificate CN
|
||||
* + sid : System ID for service
|
||||
*
|
||||
* @package App\Models
|
||||
*/
|
||||
class Service extends Model implements IDs
|
||||
{
|
||||
use NextKey;
|
||||
|
||||
const RECORD_ID = 'service';
|
||||
public $incrementing = FALSE;
|
||||
|
||||
protected $table = 'ab_service';
|
||||
const CREATED_AT = 'date_orig';
|
||||
const UPDATED_AT = 'date_last';
|
||||
|
||||
@@ -51,8 +64,6 @@ class Service extends Model
|
||||
];
|
||||
public $dateFormat = 'U';
|
||||
|
||||
protected $table = 'ab_service';
|
||||
|
||||
protected $visible = [
|
||||
'account_name',
|
||||
'admin_service_id_url',
|
||||
@@ -268,6 +279,7 @@ class Service extends Model
|
||||
->where('item_type','=',0)
|
||||
->orderBy('date_start');
|
||||
|
||||
// @todo Change to $query->active();
|
||||
if ($active)
|
||||
$query->where('active','=',TRUE);
|
||||
|
||||
@@ -344,7 +356,7 @@ class Service extends Model
|
||||
public function scopeActive($query)
|
||||
{
|
||||
return $query->where(function () use ($query) {
|
||||
$query->where('active',TRUE)
|
||||
$query->where($this->getTable().'.active',TRUE)
|
||||
->orWhereNotIn('order_status',$this->inactive_status);
|
||||
});
|
||||
}
|
||||
@@ -358,7 +370,7 @@ class Service extends Model
|
||||
public function scopeInActive($query)
|
||||
{
|
||||
return $query->where(function () use ($query) {
|
||||
$query->where('active',FALSE)
|
||||
$query->where($this->getTable().'.active',FALSE)
|
||||
->orWhereIn('order_status',$this->inactive_status);
|
||||
});
|
||||
}
|
||||
@@ -391,6 +403,7 @@ class Service extends Model
|
||||
* Name of the account for this service
|
||||
*
|
||||
* @return mixed
|
||||
* @deprecated use $this->>account->name directly
|
||||
*/
|
||||
public function getAccountNameAttribute(): string
|
||||
{
|
||||
@@ -409,6 +422,7 @@ class Service extends Model
|
||||
* Return the auto billing details
|
||||
*
|
||||
* @return mixed
|
||||
* @deprecated use billing directly?
|
||||
*/
|
||||
public function getAutoPayAttribute()
|
||||
{
|
||||
@@ -454,6 +468,7 @@ class Service extends Model
|
||||
* Date the service expires, also represents when it is paid up to
|
||||
*
|
||||
* @return string
|
||||
* @todo
|
||||
*/
|
||||
public function getExpiresAttribute(): string
|
||||
{
|
||||
@@ -613,6 +628,16 @@ class Service extends Model
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Service Local ID
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLIDattribute(): string
|
||||
{
|
||||
return sprintf('%05s',$this->id);
|
||||
}
|
||||
|
||||
public function getNameAttribute(): string
|
||||
{
|
||||
return $this->product->name_short.': '.$this->getNameShortAttribute();
|
||||
@@ -670,6 +695,7 @@ class Service extends Model
|
||||
/**
|
||||
* Get the Product's Category for this service
|
||||
*
|
||||
* @deprecated use product->category directly
|
||||
*/
|
||||
public function getProductCategoryAttribute(): string
|
||||
{
|
||||
@@ -680,6 +706,7 @@ class Service extends Model
|
||||
* Get the Product's Short Name for the service
|
||||
*
|
||||
* @return string
|
||||
* @deprecated use product->name directly
|
||||
*/
|
||||
public function getProductNameAttribute(): string
|
||||
{
|
||||
@@ -717,13 +744,13 @@ class Service extends Model
|
||||
}
|
||||
|
||||
/**
|
||||
* Services Unique Identifier
|
||||
* Services System ID
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSIDAttribute(): string
|
||||
{
|
||||
return sprintf('%02s-%04s.%05s',$this->site_id,$this->account_id,$this->id);
|
||||
return sprintf('%02s-%04s.%s',$this->site_id,$this->account_id,$this->getLIDattribute());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -849,17 +876,19 @@ class Service extends Model
|
||||
|
||||
/* SETTERS */
|
||||
|
||||
// @todo is this required?
|
||||
public function setDateOrigAttribute($value)
|
||||
{
|
||||
$this->attributes['date_orig'] = $value->timestamp;
|
||||
}
|
||||
|
||||
// @todo is this required?
|
||||
public function setDateLastAttribute($value)
|
||||
{
|
||||
$this->attributes['date_last'] = $value->timestamp;
|
||||
}
|
||||
|
||||
/* FUNCTIONS */
|
||||
/* GENERAL METHODS */
|
||||
|
||||
// The action methods will return: NULL for no progress|FALSE for a failed status|next stage name.
|
||||
|
||||
|
Reference in New Issue
Block a user