| Server IP : 34.87.99.72 / Your IP : 216.73.217.31 Web Server : Apache/2.4.46 (Unix) OpenSSL/1.1.1n System : Linux zlock-bitnami-lamp-prod-v2-vm 4.19.0-16-cloud-amd64 #1 SMP Debian 4.19.181-1 (2021-03-19) x86_64 User : bitnami ( 1000) PHP Version : 7.4.18 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /home/bitnami/htdocs/app/app/Models/ |
Upload File : |
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Pylon\Traits\Models\HasSearchScope;
class UserCredit extends Model
{
use HasSearchScope;
protected $fillable = [
];
protected $casts = [
"meta" => 'array',
];
const TOP_UP = 1;
const FREE_CREDIT = 2;
const DEDUCT_CREDIT = 3;
const DROP_OFF = 4;
const OVERTIME_CHARGE = 5;
const DROP_OFF_DELIVERY = 6;
const NEW_USER_CREDIT = 7;
public const TYPES = [
self::TOP_UP => "Top Up",
self::FREE_CREDIT => "Free Credit",
self::DEDUCT_CREDIT => "Deduct Credit",
self::DROP_OFF => "Drop Off",
self::OVERTIME_CHARGE => "Overtime Charge",
self::DROP_OFF_DELIVERY => "Drop Off (Delivery)",
self::NEW_USER_CREDIT => "New User Free Credit",
];
//Wallet Amount Cap based on operation type
const TWELVE_HOUR_OPERATION_CAP = 3.60;
const TWENTY_FOUR_HOUR_OPERATION_CAP = 6.00;
const NEW_USER_FREE_CREDIT_AMOUNT = 5;
protected $appends = [
'type_name',
];
// accessor
public function getTypeNameAttribute()
{
return self::TYPES[$this->attributes['type_id']] ?? 'N/A';
}
// relationship
public function user()
{
return $this->belongsTo('App\Models\User', 'user_id');
}
}