<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class PaymentConfig extends Model
{
    protected $table    = 'payment_config';
    protected $fillable = ['title', 'amount', 'diamond'];

    /**
     * 请求自动除100.
     *
     * @return float|int
     */
    public function getAmountAttribute($val)
    {
        return $val / 100;
    }

    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;
    }
}
