<?php

namespace App\Models;

use Dcat\Admin\Traits\HasDateTimeFormatter;

use Illuminate\Database\Eloquent\Model;

class UserMemberOrder extends Model
{
	use HasDateTimeFormatter;
    protected $table = 'user_member_orders';

    protected $fillable = [
        'user_id',
        'pay_type',
        'money',
        'status',
        'days',
        'order_no',
        'pay_time'
    ];
    protected $appends = [
        'pay_type_text',
        'status_text',
    ];
    public function payTypeStatus(){
        return [ 0 => '未知', 1 => '支付宝',2 => '银联' , 3 => 'visa' ];
    }

    public function status(){
        return [0 => '待支付', 1 => '已支付'];
    }

    public function getStatusTextAttribute()
    {
        $list = $this->status();
        return isset($list[$this->attributes['status']]) ? $list[$this->attributes['status']] : '';
    }

    public function getPayTypeTextAttribute()
    {
        $list = $this->payTypeStatus();
        return isset($list[$this->attributes['pay_type']]) ? $list[$this->attributes['pay_type']] : '';
    }
    public function user(){
        return $this->hasOne(User::class,'id','user_id');
    }
}
