<?php

namespace App\Admin\Actions\Grid;

use App\Admin\Forms\AppearanceImPortForm;
use Dcat\Admin\Grid\RowAction;
use Dcat\Admin\Widgets\Modal;
use Illuminate\Http\Request;
use App\Admin\Repositories\DistAppearance;
use App\Admin\Repositories\DistAppearanceTemplate;

class AppearanceImport extends RowAction
{
    public $sourcePath;
    public $appearanceId;
    /**
     * 返回字段标题
     *
     * @return string
     */
    public function title()
    {
        return admin_trans_label('import_tmpl');
    }

    /**
     * 初始化操作
     */
    public function render()
    {
        $form = AppearanceImPortForm::make()->payload(['id' => $this->getKey()]);
        // 实例化表单类
        return Modal::make()
            ->lg()
            ->title($this->title)
            ->body($form)
            // 因为此处使用了表单异步加载功能，所以一定要用 onLoad 方法
            ->button($this->title());
    }


    public function confirm()
    {
        return [
            "Are you sure you want to import?",
            $this->row->title,
        ];
    }

    /**
     * 设置要POST到接口的数据
     *
     * @return array
     */
    public function parameters()
    {
        return [
            // 发送当前行 username 字段数据到接口
            'title' => $this->row->title,
            'folder' => $this->row->folder
        ];
    }


}
