Optimise users home page
This commit is contained in:
@@ -3,12 +3,25 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Leenooks\Traits\ScopeActive;
|
||||
|
||||
use App\Interfaces\IDs;
|
||||
use App\Traits\NextKey;
|
||||
|
||||
class Account extends Model
|
||||
/**
|
||||
* Class Account
|
||||
* Service Accounts
|
||||
*
|
||||
* Attributes for accounts:
|
||||
* + lid: : Local ID for account
|
||||
* + sid: : System ID for account
|
||||
*
|
||||
* @package App\Models
|
||||
*/
|
||||
class Account extends Model implements IDs
|
||||
{
|
||||
use NextKey;
|
||||
use NextKey,ScopeActive;
|
||||
|
||||
const RECORD_ID = 'account';
|
||||
public $incrementing = FALSE;
|
||||
|
||||
@@ -29,6 +42,8 @@ class Account extends Model
|
||||
'switch_url',
|
||||
];
|
||||
|
||||
/* RELATIONS */
|
||||
|
||||
/**
|
||||
* Return the country the user belongs to
|
||||
*/
|
||||
@@ -69,15 +84,7 @@ class Account extends Model
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
/** SCOPES */
|
||||
|
||||
/**
|
||||
* Only query active categories
|
||||
*/
|
||||
public function scopeActive($query)
|
||||
{
|
||||
return $query->where('active',TRUE);
|
||||
}
|
||||
/* SCOPES */
|
||||
|
||||
/**
|
||||
* Search for a record
|
||||
@@ -118,7 +125,7 @@ class Account extends Model
|
||||
return $query;
|
||||
}
|
||||
|
||||
/** ATTRIBUTES **/
|
||||
/* ATTRIBUTES */
|
||||
|
||||
public function getActiveDisplayAttribute($value)
|
||||
{
|
||||
@@ -144,10 +151,21 @@ class Account extends Model
|
||||
/**
|
||||
* Return the Account Unique Identifier
|
||||
* @return string
|
||||
* @deprecated use getSIDAttribute()
|
||||
*/
|
||||
public function getAIDAttribute()
|
||||
{
|
||||
return sprintf('%02s-%04s',$this->site_id,$this->id);
|
||||
return $this->getSIDAttribute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Account Local ID
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLIDAttribute(): string
|
||||
{
|
||||
return sprintf('%04s',$this->id);
|
||||
}
|
||||
|
||||
public function getNameAttribute()
|
||||
@@ -160,9 +178,19 @@ class Account extends Model
|
||||
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()
|
||||
{
|
||||
return sprintf('<a href="/r/switch/start/%s"><i class="fa fa-external-link"></i></a>',$this->user_id);
|
||||
return sprintf('<a href="/r/switch/start/%s"><i class="fas fa-external-link-alt"></i></a>',$this->user_id);
|
||||
}
|
||||
|
||||
public function getTypeAttribute()
|
||||
|
Reference in New Issue
Block a user