<?php

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

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

class UserStatusInit extends RowAction
{

    public $name = '正常';

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

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

}