<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Withdraw extends Model
{
    protected $fillable = ['user_id', 'type', 'bank_name', 'name', 'number', 'state', 'amount', 'procedure', 'practical_amount', 'not_desc', 'created_at', 'updated_at'];

    protected $table = 'withdraw';
    public static $label = [1 => '微信余额', 2 => '支付宝' , 3 => '银行卡'];
    public static $state = [0 => '待审核', 1 => '已提现' , 2 => '已拒绝'];
    public function getCreatedAtAttribute($value)
    {
        $dateTime = new \DateTime($value);

        // 格式化时间
        $formattedTime = $dateTime->format('Y-m-d H:i:s');

        return $formattedTime;
    }

    public function getUpdatedAtAttribute($value)
    {
        $dateTime = new \DateTime($value);

        // 格式化时间
        $formattedTime = $dateTime->format('Y-m-d H:i:s');

        return $formattedTime;
    }
    public function userData(){
        return $this->hasOne(User::class,'id','user_id');
    }
}
