jingcai-php/app/Model/Customer/CustomerRanking.php

36 lines
743 B
PHP
Executable File

<?php
namespace App\Model\Customer;
use App\Model\BaseModel;
use App\Utils\Helps;
class CustomerRanking extends BaseModel
{
protected $appends = [
'profit_lv5',
'profit_lv3',
'profit_lv2',
];
public function customer()
{
return $this->belongsTo(Customer::class, 'customer_id', 'id');
}
public function getProfitLv5Attribute()
{
return Helps::percentage($this->total_prize5, $this->total_money5);
}
public function getProfitLv3Attribute()
{
return Helps::percentage($this->total_prize3, $this->total_money3);
}
public function getProfitLv2Attribute()
{
return Helps::percentage($this->total_prize2, $this->total_money2);
}
}