Wire admin studio SSR and search infrastructure
This commit is contained in:
@@ -5,21 +5,24 @@ namespace App\Http\Controllers\Web;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Services\ArtworkService;
|
||||
use App\Services\CategoryDirectoryService;
|
||||
use App\Models\Category;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
|
||||
class CategoryController extends Controller
|
||||
{
|
||||
protected ArtworkService $artworkService;
|
||||
protected CategoryDirectoryService $categoryDirectory;
|
||||
|
||||
public function __construct(ArtworkService $artworkService)
|
||||
public function __construct(ArtworkService $artworkService, CategoryDirectoryService $categoryDirectory)
|
||||
{
|
||||
$this->artworkService = $artworkService;
|
||||
$this->categoryDirectory = $categoryDirectory;
|
||||
}
|
||||
|
||||
public function index(Request $request)
|
||||
{
|
||||
return $this->browseCategories();
|
||||
return $this->browseCategories($request);
|
||||
}
|
||||
|
||||
public function show(Request $request, $id, $slug = null, $group = null)
|
||||
@@ -58,20 +61,7 @@ class CategoryController extends Controller
|
||||
}
|
||||
|
||||
try {
|
||||
$category = Category::whereHas('contentType', function ($q) use ($contentTypeSlug) {
|
||||
$q->where('slug', strtolower($contentTypeSlug));
|
||||
})->whereNull('parent_id')->where('slug', strtolower($parts[0] ?? ''))->first();
|
||||
|
||||
if ($category && count($parts) > 1) {
|
||||
$cur = $category;
|
||||
foreach (array_slice($parts, 1) as $slugPart) {
|
||||
$cur = $cur->children()->where('slug', strtolower($slugPart))->first();
|
||||
if (! $cur) {
|
||||
abort(404);
|
||||
}
|
||||
}
|
||||
$category = $cur;
|
||||
}
|
||||
$category = $this->artworkService->resolveCategoryByPath($slugs);
|
||||
} catch (\Throwable $e) {
|
||||
$category = null;
|
||||
}
|
||||
@@ -109,12 +99,19 @@ class CategoryController extends Controller
|
||||
));
|
||||
}
|
||||
|
||||
public function browseCategories()
|
||||
public function browseCategories(Request $request)
|
||||
{
|
||||
$pageTitle = 'All Categories – Wallpapers, Skins & Digital Art | Skinbase';
|
||||
$pageDescription = 'Browse all categories on Skinbase including wallpapers, skins, themes, and digital art collections.';
|
||||
$payload = $this->categoryDirectory->getDirectoryPayload(
|
||||
(string) $request->query('q', ''),
|
||||
(string) $request->query('sort', 'popular'),
|
||||
(int) $request->query('page', 1),
|
||||
(int) $request->query('per_page', 24),
|
||||
);
|
||||
|
||||
return view('web.categories', [
|
||||
'initialPayload' => $payload,
|
||||
'page_title' => $pageTitle,
|
||||
'page_meta_description' => $pageDescription,
|
||||
'page_canonical' => url('/categories'),
|
||||
|
||||
Reference in New Issue
Block a user