<?php

namespace App\Admin\Actions\Form;

use App\Models\UserEpisodesRecord;
use Dcat\Admin\Contracts\LazyRenderable;
use Dcat\Admin\Traits\LazyWidget;
use Dcat\Admin\Widgets\Form;

class UserRechargeRemark extends Form implements LazyRenderable
{
    use LazyWidget;

    public function handle(array $input)
    {
        if (!$input['remark']) {
            return $this->response()->error('请填写备注');
        }

        UserEpisodesRecord::where('id', $input['id'])->update(['remark' => $input['remark']]);

        return $this->response()->success('修改成功')->refresh();
    }

    public function form()
    {
        $this->textarea('remark', '备注');
        $this->hidden('id')->attribute('id', 'recharge-id');
    }
}
