<?php

namespace Modules\User\Http\Controllers\Admin\Actions;

use Encore\Admin\Actions\Response;
use Encore\Admin\Actions\RowAction;
use Modules\User\Models\Order;

class Refund extends RowAction
{

    public $name = '退款';

    public function handle(Order $order): Response
    {
        try {
            $order->refund();

            return $this->response()->success('退款成功')->refresh();
        } catch (\Exception $exception) {
            return $this->response()->error($exception->getMessage())->refresh();
        }
    }

}