You've already forked Atomcms-edit
81 lines
2.3 KiB
PHP
81 lines
2.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Http\Controllers\Api;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\Game\Furniture\CatalogItem;
|
|
use App\Models\Game\Furniture\CatalogPage;
|
|
use App\Models\Game\Guild\Guild;
|
|
use App\Models\Miscellaneous\WebsiteSetting;
|
|
use App\Services\Community\StaffService;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
|
class ContentApiController extends Controller
|
|
{
|
|
public function __construct(
|
|
private readonly StaffService $staffService,
|
|
) {}
|
|
|
|
public function settings(): JsonResponse
|
|
{
|
|
$settings = Cache::remember('api_all_settings', 60, fn () => WebsiteSetting::all()->pluck('value', 'key'));
|
|
|
|
return response()->json(['data' => $settings]);
|
|
}
|
|
|
|
public function staff(): JsonResponse
|
|
{
|
|
return response()->json(['data' => $this->staffService->fetchStaffPositions()]);
|
|
}
|
|
|
|
public function teams(): JsonResponse
|
|
{
|
|
$teams = Guild::with('members')->latest('id')->paginate(12);
|
|
|
|
return response()->json([
|
|
'data' => $teams->items(),
|
|
'meta' => [
|
|
'current_page' => $teams->currentPage(),
|
|
'last_page' => $teams->lastPage(),
|
|
'per_page' => $teams->perPage(),
|
|
'total' => $teams->total(),
|
|
],
|
|
]);
|
|
}
|
|
|
|
public function rareValues(Request $request): JsonResponse
|
|
{
|
|
$query = CatalogItem::query();
|
|
|
|
if ($categoryId = $request->query('category')) {
|
|
$query->where('page_id', $categoryId);
|
|
}
|
|
|
|
$items = $query->with('itemBase')->latest('id')->paginate(24);
|
|
|
|
return response()->json([
|
|
'data' => $items->items(),
|
|
'meta' => [
|
|
'current_page' => $items->currentPage(),
|
|
'last_page' => $items->lastPage(),
|
|
'per_page' => $items->perPage(),
|
|
'total' => $items->total(),
|
|
],
|
|
]);
|
|
}
|
|
|
|
public function rareValuesCategories(): JsonResponse
|
|
{
|
|
$categories = CatalogPage::where('catalog_name', '!=', '')
|
|
->where('visible', 1)
|
|
->orderBy('order_number')
|
|
->get(['id', 'catalog_name', 'icon']);
|
|
|
|
return response()->json(['data' => $categories]);
|
|
}
|
|
}
|