<?php

namespace App\Models;

use App\Constants\HttpStatus;
use App\Constants\Util;
use Illuminate\Foundation\Auth\User as Authenticatable;

use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;
use Illuminate\Database\Eloquent\Builder;

/**
 * @mixin Builder
 * @method static Builder|static where($column, $operator = null, $value = null, $boolean = 'and')
 */
class Collect extends Authenticatable
{
    use HasApiTokens, Notifiable;

    protected $table = 'collects';
    protected $hidden = ['created_at', 'updated_at'];
    // ✅ 允许批量赋值的字段
    protected $fillable = [
        'from_address',
        'to_address',
        'amount',
        'coin',
        'net',
        'status',
        'txid',
        'fee',
        'confirmations',
        'block_number',
        'remark',
    ];

    const STATUS_STAY = 0;
    const STATUS_START = 1;
    const STATUS_SUCCESS = 2;
    const STATUS_FAIL = 3;

    public static $STATUS = [
        0 => '待处理',
        1 => '已发起',
        2 => '已确认',
        3 => '失败',
    ];

    protected function getCreatedAtAttribute($value)
    {
        return \Carbon\Carbon::parse($value)->setTimezone('Asia/Shanghai')->format('Y-m-d H:i:s');
    }

    protected function getUpdatedAtAttribute($value)
    {
        return \Carbon\Carbon::parse($value)->setTimezone('Asia/Shanghai')->format('Y-m-d H:i:s');
    }
}
