<?php

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

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

class UserStatusRefund extends RowAction
{

    public $name = '已退费';

    public function handle(User $user): Response
    {
        try {
            $user->update([
                'status' => User::STATUS_REFUND
            ]);

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

}