Optimise users home page
This commit is contained in:
@@ -4,12 +4,25 @@ namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
use App\Traits\PushNew;
|
||||
use App\Traits\NextKey;
|
||||
use App\Interfaces\IDs;
|
||||
use App\Traits\{NextKey,PushNew};
|
||||
|
||||
class Payment extends Model
|
||||
/**
|
||||
* Class Payment
|
||||
* Payments that belong to an account
|
||||
*
|
||||
* Attributes for payments:
|
||||
* + lid : Local ID for payment
|
||||
* + payment_date : Date payment received
|
||||
* + sid : System ID for payment
|
||||
* + total : Payment total
|
||||
*
|
||||
* @package App\Models
|
||||
*/
|
||||
class Payment extends Model implements IDs
|
||||
{
|
||||
use NextKey,PushNew;
|
||||
|
||||
const RECORD_ID = 'payment';
|
||||
public $incrementing = FALSE;
|
||||
|
||||
@@ -24,6 +37,8 @@ class Payment extends Model
|
||||
// Array of items that can be updated with PushNew
|
||||
protected $pushable = ['items'];
|
||||
|
||||
/* RELATIONS */
|
||||
|
||||
public function account()
|
||||
{
|
||||
return $this->belongsTo(Account::class);
|
||||
@@ -34,11 +49,37 @@ class Payment extends Model
|
||||
return $this->hasMany(PaymentItem::class);
|
||||
}
|
||||
|
||||
/* ATTRIBUTES */
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
* @deprecated use date_payment directly.
|
||||
*/
|
||||
public function getDatePaidAttribute()
|
||||
{
|
||||
return $this->date_payment->format('Y-m-d');
|
||||
}
|
||||
|
||||
/**
|
||||
* Payment Local ID
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLIDattribute(): string
|
||||
{
|
||||
return sprintf('%06s',$this->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Payment System ID
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSIDAttribute(): string
|
||||
{
|
||||
return sprintf('%02s-%04s#%s',$this->site_id,$this->account_id,$this->getLIDattribute());
|
||||
}
|
||||
|
||||
public function getTotalAttribute()
|
||||
{
|
||||
return sprintf('%3.'.$this->currency()->rounding.'f',$this->total_amt);
|
||||
|
Reference in New Issue
Block a user