fixed browse and tailwindcss style
This commit is contained in:
@@ -4,13 +4,15 @@ namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Category;
|
||||
use App\Models\ContentType;
|
||||
use App\Models\Artwork;
|
||||
use App\Services\ArtworkService;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
|
||||
class CategoryPageController extends Controller
|
||||
{
|
||||
public function __construct(private ArtworkService $artworkService)
|
||||
{
|
||||
}
|
||||
|
||||
public function show(Request $request, string $contentTypeSlug, ?string $categoryPath = null)
|
||||
{
|
||||
$contentType = ContentType::where('slug', strtolower($contentTypeSlug))->first();
|
||||
@@ -18,6 +20,8 @@ class CategoryPageController extends Controller
|
||||
abort(404);
|
||||
}
|
||||
|
||||
$sort = (string) $request->get('sort', 'latest');
|
||||
|
||||
|
||||
if ($categoryPath === null || $categoryPath === '') {
|
||||
// No category path: show content-type landing page (e.g., /wallpapers)
|
||||
@@ -27,20 +31,7 @@ class CategoryPageController extends Controller
|
||||
|
||||
// Load artworks for this content type (show gallery on the root page)
|
||||
$perPage = 40;
|
||||
$artworks = Artwork::whereHas('categories', function ($q) use ($contentType) {
|
||||
$q->where('categories.content_type_id', $contentType->id);
|
||||
})
|
||||
->published()->public()
|
||||
->with([
|
||||
'user:id,name',
|
||||
'categories' => function ($q) {
|
||||
$q->select('categories.id', 'categories.content_type_id', 'categories.parent_id', 'categories.name', 'categories.slug', 'categories.sort_order')
|
||||
->with(['parent:id,parent_id,content_type_id,name,slug', 'contentType:id,slug,name']);
|
||||
},
|
||||
])
|
||||
->orderBy('published_at', 'desc')
|
||||
->paginate($perPage)
|
||||
->withQueryString();
|
||||
$artworks = $this->artworkService->getArtworksByContentType($contentType->slug, $perPage, $sort);
|
||||
|
||||
return view('legacy.content-type', compact(
|
||||
'contentType',
|
||||
@@ -88,10 +79,9 @@ class CategoryPageController extends Controller
|
||||
// Load artworks via ArtworkService to support arbitrary-depth category paths
|
||||
$perPage = 40;
|
||||
try {
|
||||
$service = app(ArtworkService::class);
|
||||
// service expects an array with contentType slug first, then category slugs
|
||||
$pathSlugs = array_merge([strtolower($contentTypeSlug)], $slugs);
|
||||
$artworks = $service->getArtworksByCategoryPath($pathSlugs, $perPage);
|
||||
$artworks = $this->artworkService->getArtworksByCategoryPath($pathSlugs, $perPage, $sort);
|
||||
} catch (\Throwable $e) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user