<?php

namespace Modules\Mall\Http\Controllers\Admin\Action\Shop;

use Encore\Admin\Actions\Response;
use Encore\Admin\Actions\RowAction;
use Modules\Mall\Models\Shop;

class Close extends RowAction
{

    public $name = '关闭店铺';

    public function handle(Shop $shop): Response
    {
        try {
            if ($shop->close()) {
                return $this->response()->success('店铺关闭成功')->refresh();
            } else {
                return $this->response()->error('店铺关闭失败')->refresh();
            }
        } catch (\Exception $exception) {
            return $this->response()->error($exception->getMessage())->refresh();
        }
    }

    public function dialog()
    {
        $this->confirm('确定关闭店铺吗？');
    }

}
