fix: deep link

This commit is contained in:
2026-09-02 11:16:03 +03:30
parent a3cda12560
commit 78ea663c2b
4 changed files with 37 additions and 15 deletions
+17 -6
View File
@@ -132,15 +132,24 @@ public function show($id)
return response()->json($category);
}
// Public (no auth) deep link lookup by ID. Hidden (deeplink-only) categories
// are the only ones served here, since they are discovered via the deep link.
// Public (no auth) deep link lookup by ID. Serves any category — hidden
// (deeplink-only) ones included — so https://aramejan.com/category/{id}
// resolves for every shareable category. A visible category only lists its
// visible media; inside a hidden category everything is shown, since the
// deep link is the only way in.
public function publicShow($id)
{
$category = Category::with(['subcategories' => function ($q) {
$q->orderBy('name')->with(['media' => function ($m) {
$category = Category::findOrFail($id);
$includeHiddenMedia = (bool) $category->is_deeplink_only;
$category->load(['subcategories' => function ($q) use ($includeHiddenMedia) {
$q->orderBy('name')->with(['media' => function ($m) use ($includeHiddenMedia) {
if (! $includeHiddenMedia) {
$m->where('is_deeplink_only', false);
}
$m->with(['image', 'detailImage', 'tags'])->latest();
}]);
}])->where('id', $id)->where('is_deeplink_only', true)->firstOrFail();
}]);
return response()->json([
'category' => [
@@ -169,7 +178,9 @@ public function grouped($id)
{
$category = Category::with(['subcategories' => function ($q) {
$q->orderBy('name')->with(['media' => function ($m) {
$m->with(['image', 'detailImage', 'tags'])->latest();
// Deep-link-only media stays out of the normal category screen.
$m->where('is_deeplink_only', false)
->with(['image', 'detailImage', 'tags'])->latest();
}]);
}])->findOrFail($id);