12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <?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>';
- }
- }
|