- 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
110 lines
3.2 KiB
PHP
Executable File
110 lines
3.2 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Http\Controllers\Web\Admin;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Http\Requests\StoreRequest;
|
|
use App\Models\AiAgent;
|
|
use App\Models\Store;
|
|
use App\Models\User;
|
|
use Illuminate\Http\RedirectResponse;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\View\View;
|
|
|
|
/**
|
|
* Administrative store management (admin only).
|
|
*
|
|
* Provides the server-rendered CRUD screens where administrators create
|
|
* and edit stores, defining their exact 3D placement in the virtual city
|
|
* through a Three.js position picker.
|
|
*/
|
|
class StoreAdminController extends Controller
|
|
{
|
|
/**
|
|
* Paginated listing of every store with search and type filtering.
|
|
*/
|
|
public function index(Request $request): View
|
|
{
|
|
$query = Store::query()->with(['owner:id,name', 'agent:id,name'])->orderBy('name');
|
|
|
|
if ($search = $request->query('search')) {
|
|
$query->where('name', 'like', "%{$search}%");
|
|
}
|
|
|
|
if ($type = $request->query('type')) {
|
|
$query->where('type', $type);
|
|
}
|
|
|
|
$types = Store::query()->select('type')->distinct()->orderBy('type')->pluck('type');
|
|
|
|
return view('admin.stores.index', [
|
|
'stores' => $query->paginate(12)->withQueryString(),
|
|
'types' => $types,
|
|
'currentSearch' => $search,
|
|
'currentType' => $type,
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Show the store creation form with the 3D position picker.
|
|
*/
|
|
public function create(): View
|
|
{
|
|
return view('admin.stores.form', [
|
|
'store' => new Store(['is_open' => true, 'pos_x' => 0, 'pos_y' => 0, 'pos_z' => 0, 'width' => 8, 'height' => 6, 'depth' => 8]),
|
|
'owners' => User::query()->orderBy('name')->get(['id', 'name', 'email']),
|
|
'agents' => AiAgent::query()->orderBy('name')->get(['id', 'name', 'type']),
|
|
'isEdit' => false,
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Persist a newly created store.
|
|
*/
|
|
public function store(StoreRequest $request): RedirectResponse
|
|
{
|
|
$store = Store::create($request->validated());
|
|
|
|
return redirect()
|
|
->route('admin.stores.edit', $store)
|
|
->with('status', __('admin.stores.created'));
|
|
}
|
|
|
|
/**
|
|
* Show the store edit form pre-filled with the current 3D placement.
|
|
*/
|
|
public function edit(Store $store): View
|
|
{
|
|
return view('admin.stores.form', [
|
|
'store' => $store,
|
|
'owners' => User::query()->orderBy('name')->get(['id', 'name', 'email']),
|
|
'agents' => AiAgent::query()->orderBy('name')->get(['id', 'name', 'type']),
|
|
'isEdit' => true,
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Update an existing store.
|
|
*/
|
|
public function update(StoreRequest $request, Store $store): RedirectResponse
|
|
{
|
|
$store->update($request->validated());
|
|
|
|
return redirect()
|
|
->route('admin.stores.index')
|
|
->with('status', __('admin.stores.updated'));
|
|
}
|
|
|
|
/**
|
|
* Delete a store from the city registry.
|
|
*/
|
|
public function destroy(Store $store): RedirectResponse
|
|
{
|
|
$store->delete();
|
|
|
|
return redirect()
|
|
->route('admin.stores.index')
|
|
->with('status', __('stores.deleted'));
|
|
}
|
|
}
|