Home screen improvements, testing for role, work on user/account models
This commit is contained in:
@@ -24,25 +24,17 @@ class Account extends Model implements IDs
|
||||
{
|
||||
use HasFactory,ScopeActive;
|
||||
|
||||
const CREATED_AT = 'date_orig';
|
||||
const UPDATED_AT = 'date_last';
|
||||
/* INTERFACES */
|
||||
|
||||
protected $appends = [
|
||||
'active_display',
|
||||
'name',
|
||||
'services_count_html',
|
||||
'switch_url',
|
||||
];
|
||||
public function getLIDAttribute(): string
|
||||
{
|
||||
return sprintf('%04s',$this->id);
|
||||
}
|
||||
|
||||
public $dateFormat = 'U';
|
||||
|
||||
protected $visible = [
|
||||
'id',
|
||||
'active_display',
|
||||
'name',
|
||||
'services_count_html',
|
||||
'switch_url',
|
||||
];
|
||||
public function getSIDAttribute(): string
|
||||
{
|
||||
return sprintf('%02s-%s',$this->site_id,$this->getLIDAttribute());
|
||||
}
|
||||
|
||||
/* RELATIONS */
|
||||
|
||||
@@ -135,6 +127,7 @@ class Account extends Model implements IDs
|
||||
|
||||
public function getActiveDisplayAttribute($value)
|
||||
{
|
||||
abort(500,'deprecated');
|
||||
return sprintf('<span class="btn-sm btn-block btn-%s text-center">%s</span>',$this->active ? 'success' : 'danger',$this->active ? 'Active' : 'Inactive');
|
||||
}
|
||||
|
||||
@@ -143,6 +136,7 @@ class Account extends Model implements IDs
|
||||
*/
|
||||
public function getAccountIdAttribute()
|
||||
{
|
||||
abort(500,'deprecated');
|
||||
return $this->getAIDAttribute();
|
||||
}
|
||||
|
||||
@@ -151,6 +145,7 @@ class Account extends Model implements IDs
|
||||
*/
|
||||
public function getAccountIdUrlAttribute()
|
||||
{
|
||||
abort(500,'deprecated');
|
||||
return $this->getUrlAdminAttribute();
|
||||
}
|
||||
|
||||
@@ -175,41 +170,29 @@ class Account extends Model implements IDs
|
||||
*/
|
||||
public function getAIDAttribute()
|
||||
{
|
||||
abort(500,'deprecated');
|
||||
return $this->getSIDAttribute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Account Local ID
|
||||
* Return the account name
|
||||
*
|
||||
* @return string
|
||||
* @return mixed|string
|
||||
*/
|
||||
public function getLIDAttribute(): string
|
||||
{
|
||||
return sprintf('%04s',$this->id);
|
||||
}
|
||||
|
||||
public function getNameAttribute()
|
||||
public function getNameAttribute(): string
|
||||
{
|
||||
return $this->company ?: ($this->user_id ? $this->user->SurFirstName : 'AID:'.$this->id);
|
||||
}
|
||||
|
||||
public function getServicesCountHtmlAttribute()
|
||||
{
|
||||
abort(500,'deprecated');
|
||||
return sprintf('%s <small>/%s</small>',$this->services()->noEagerLoads()->where('active',TRUE)->count(),$this->services()->noEagerLoads()->count());
|
||||
}
|
||||
|
||||
/**
|
||||
* Account System ID
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSIDAttribute(): string
|
||||
{
|
||||
return sprintf('%02s-%s',$this->site_id,$this->getLIDAttribute());
|
||||
}
|
||||
|
||||
public function getSwitchUrlAttribute()
|
||||
{
|
||||
abort(500,'deprecated');
|
||||
return sprintf('<a href="/r/switch/start/%s"><i class="fas fa-external-link-alt"></i></a>',$this->user_id);
|
||||
}
|
||||
|
||||
@@ -225,6 +208,7 @@ class Account extends Model implements IDs
|
||||
*/
|
||||
public function getUrlAdminAttribute(): string
|
||||
{
|
||||
abort(500,'deprecated');
|
||||
return sprintf('<a href="/r/account/view/%s">%s</a>',$this->id,$this->account_id);
|
||||
}
|
||||
|
||||
@@ -235,6 +219,7 @@ class Account extends Model implements IDs
|
||||
*/
|
||||
public function getUrlUserAttribute(): string
|
||||
{
|
||||
abort(500,'deprecated');
|
||||
return sprintf('<a href="/u/account/view/%s">%s</a>',$this->id,$this->account_id);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user