<?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 Pass extends RowAction
{

    public $name = '审核通过';

    public function handle(Shop $shop): Response
    {
        try {
            if ($shop->pass()) {
                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('确定审核通过？');
    }

}
