| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 | <?phpnamespace 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);    }}
 |