- 字体颜色:s_color 改为 varchar,发消息时保存颜色,进入聊天室自动恢复 - 等级体系:maxlevel 15→99,superlevel 16→100,99级经验阶梯(幂次曲线) - 管理权限等级按比例调整:禁言50、踢人60、设公告60、封号80、封IP90 - 钓鱼小游戏:FishingController(抛竿扣金币+收竿随机结果+广播) - 补充6个缺失的 sysparam 参数 + 4个钓鱼参数 - 用户列表点击用户名后自动聚焦输入框 - Pint 格式化
98 lines
2.5 KiB
PHP
98 lines
2.5 KiB
PHP
<?php
|
|
|
|
/**
|
|
* 文件功能:自动事件管理控制器
|
|
* 管理员可在后台增删改随机事件(好运/坏运/经验/金币奖惩等)
|
|
* 复刻原版 ASP 聊天室的 autoact 管理功能
|
|
*
|
|
* @author ChatRoom Laravel
|
|
*
|
|
* @version 1.0.0
|
|
*/
|
|
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\Autoact;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\RedirectResponse;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\View\View;
|
|
|
|
class AutoactController extends Controller
|
|
{
|
|
/**
|
|
* 显示所有自动事件列表
|
|
*/
|
|
public function index(): View
|
|
{
|
|
$events = Autoact::orderByDesc('id')->get();
|
|
|
|
return view('admin.autoact.index', compact('events'));
|
|
}
|
|
|
|
/**
|
|
* 保存新事件
|
|
*/
|
|
public function store(Request $request): RedirectResponse
|
|
{
|
|
$data = $request->validate([
|
|
'text_body' => 'required|string|max:500',
|
|
'event_type' => 'required|in:good,bad,neutral',
|
|
'exp_change' => 'required|integer',
|
|
'jjb_change' => 'required|integer',
|
|
]);
|
|
|
|
$data['enabled'] = true;
|
|
|
|
Autoact::create($data);
|
|
|
|
return redirect()->route('admin.autoact.index')->with('success', '事件添加成功!');
|
|
}
|
|
|
|
/**
|
|
* 更新事件
|
|
*/
|
|
public function update(Request $request, int $id): RedirectResponse
|
|
{
|
|
$event = Autoact::findOrFail($id);
|
|
|
|
$data = $request->validate([
|
|
'text_body' => 'required|string|max:500',
|
|
'event_type' => 'required|in:good,bad,neutral',
|
|
'exp_change' => 'required|integer',
|
|
'jjb_change' => 'required|integer',
|
|
]);
|
|
|
|
$event->update($data);
|
|
|
|
return redirect()->route('admin.autoact.index')->with('success', '事件修改成功!');
|
|
}
|
|
|
|
/**
|
|
* 切换事件启用/禁用状态
|
|
*/
|
|
public function toggle(int $id): JsonResponse
|
|
{
|
|
$event = Autoact::findOrFail($id);
|
|
$event->enabled = ! $event->enabled;
|
|
$event->save();
|
|
|
|
return response()->json([
|
|
'status' => 'success',
|
|
'enabled' => $event->enabled,
|
|
'message' => $event->enabled ? '已启用' : '已禁用',
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* 删除事件
|
|
*/
|
|
public function destroy(int $id): RedirectResponse
|
|
{
|
|
Autoact::findOrFail($id)->delete();
|
|
|
|
return redirect()->route('admin.autoact.index')->with('success', '事件已删除!');
|
|
}
|
|
}
|