feat(world): add persistent citizen simulation with needs, jobs, and social features
- Adds Character model with survival needs (hunger, thirst, energy) and state machine - Implements city:tick world ticker for offline progression every minute - Adds city territory expansion and building construction system - Introduces job economy, inventory, and transaction audit trail - Adds social graph (friends, marriage, children) and character chat - Implements admin approval workflow for new registrations - Adds hospital admission system for traffic accidents - Includes comprehensive feature tests and world seeders
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Web\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Character;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
|
||||
/**
|
||||
* Administrator management of citizen accounts.
|
||||
*
|
||||
* Lists registered users, approves pending registrations (which creates the
|
||||
* in-world character) and bans accounts that must not enter the platform.
|
||||
*/
|
||||
class CitizenAdminController extends Controller
|
||||
{
|
||||
/**
|
||||
* List all citizens with their approval status.
|
||||
*/
|
||||
public function index(Request $request): View
|
||||
{
|
||||
abort_unless($request->user()?->isAdmin(), 403);
|
||||
|
||||
$users = User::query()
|
||||
->with('character:id,user_id,name,city_id')
|
||||
->orderByDesc('created_at')
|
||||
->paginate(20);
|
||||
|
||||
return view('admin.citizens.index', [
|
||||
'users' => $users,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Approve a pending citizen and ensure their character exists.
|
||||
*/
|
||||
public function approve(Request $request, User $user): RedirectResponse
|
||||
{
|
||||
abort_unless($request->user()?->isAdmin(), 403);
|
||||
|
||||
$user->forceFill(['status' => User::STATUS_ACTIVE, 'is_active' => true])->save();
|
||||
Character::ensureForUser($user);
|
||||
|
||||
return redirect()->route('admin.citizens.index')
|
||||
->with('status', __('admin.citizens.approved'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Ban a citizen so they can no longer authenticate.
|
||||
*/
|
||||
public function ban(Request $request, User $user): RedirectResponse
|
||||
{
|
||||
abort_unless($request->user()?->isAdmin(), 403);
|
||||
|
||||
abort_if((int) $user->id === (int) $request->user()->id, 422, __('admin.citizens.cannot_ban_self'));
|
||||
|
||||
$user->forceFill(['status' => User::STATUS_BANNED, 'is_active' => false])->save();
|
||||
|
||||
return redirect()->route('admin.citizens.index')
|
||||
->with('status', __('admin.citizens.banned'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user