1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- <?php
- namespace App\Models;
- use Illuminate\Database\Eloquent\Model;
- class Order extends Model
- {
- protected $table = 'orders';
- protected $guarded = [];
- public $pay_statuses;
- public function __construct(array $attributes = [])
- {
- parent::__construct($attributes);
- $this->pay_statuses = collect([
- collect(['key' => 1, 'value' => '未付款']),
- collect(['key' => 2, 'value' => '已付款']),
- collect(['key' => 3, 'value' => '已退款']),
- collect(['key' => 4, 'value' => '已取消']),
- collect(['key' => 5, 'value' => '回收站']),
- ]);
- }
- public function student()
- {
- return $this->belongsTo('App\Models\Student');
- }
- public function getPayStatuses()
- {
- return $this->pay_statuses;
- }
- public function getStudentName()
- {
- return empty($this['student']) ? '' : $this['student']['name'];
- }
- public function getPayPosition()
- {
- return '落地页' . $this['pay_position'] . '付款';
- }
- public function getPayStatusLabel()
- {
- switch($this['pay_status']) {
- case 1:
- return '<span class="label label-default">未付款</span>';
- case 2:
- return '<span class="label label-info">已付款</span>';
- case 3:
- return '<span class="label label-danger">已退款</span>';
- case 4:
- return '<span class="label label-warning">已取消</span>';
- case 5:
- return '<span class="label label-info">回收站</span>';
- default:
- return '<span class="label label-default">未付款</span>';
- }
- }
- public function getPayMethodLabel()
- {
- return '<span class="label label-primary">微信支付</span>';
- }
- public function getOutTradeNo()
- {
- return date('YmdHis') . rand(10, 99);
- }
- public function getPayMoney()
- {
- return round($this['money'] / 100, 2);
- }
- }
|