You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
aquaculture/app/Admin/Actions/Post/ActiveUserAction.php

32 lines
777 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<?php
namespace App\Admin\Actions\Post;
use App\Models\User;
use Encore\Admin\Actions\RowAction;
use Illuminate\Database\Eloquent\Model;
class ActiveUserAction extends RowAction
{
// 动作名称,显示在界面上的按钮文本
public $name = '激活';
/**
* 处理激活用户的逻辑
*
* @param User $model 被激活的用户模型
* @return \Encore\Admin\Actions\Response 返回操作结果的响应
*/
public function handle(User $model)
{
// 将用户的激活状态设置为 1激活
$model->is_active = 1;
// 保存用户模型的更改
$model->save();
// 返回成功响应并刷新页面
return $this->response()->success('操作成功.')->refresh();
}
}