<?php

namespace App\Admin\Actions\Grid;

use Dcat\Admin\Contracts\LazyRenderable;
use Dcat\Admin\Grid\RowAction;
use Dcat\Admin\Traits\LazyWidget;
use Dcat\Admin\Widgets\Modal;

class UserRechargeRemark extends RowAction implements LazyRenderable
{
    use LazyWidget;

    /**
     * @return string
     */
    protected $title = '备注';

    public function render()
    {
        $form = \App\Admin\Actions\Form\UserRechargeRemark::make();

        return Modal::make()
            ->lg()
            ->title($this->title)
            ->body($form)
            ->onLoad($this->getModalScript())
            ->button($this->title);
    }

    protected function getModalScript()
    {
        return <<<JS
//获取选中的ID
let key = {$this->getKey()}
$("#recharge-id").val(key)
JS;
    }
}
