<?php

namespace App\Distributor\Actions;


use App\Distributor\Repositories\DistAdminDistributor;
use Dcat\Admin\Grid\RowAction;
use Illuminate\Http\Request;

class AppearanceEnable extends RowAction
{

    /**
     * 返回字段标题
     *
     * @return string
     */
    public function title()
    {
        return '<i class="feather icon-check-circle"></i>&nbsp;&nbsp;'.admin_trans_label('enable');
    }

    public function confirm()
    {
        $msg = admin_trans_label('confirm_enable_appearance');
        return [
            $msg,
            $this->row->title,
        ];
    }
    /*
     * 处理请求
     */
    public function handle(Request $request)
    {
        $appearanceId = $this->getKey();
        DistAdminDistributor::enableTheme($appearanceId);
        // 返回响应结果并刷新页面
        return $this->response()->success(admin_trans_label('update_success'))->refresh();
    }
    /**
     * 设置要POST到接口的数据
     *
     * @return array
     */
    public function parameters()
    {
        return [
            // 发送当前行 username 字段数据到接口
            'id' => $this->row->title,
        ];
    }

}
