fixed gallery
This commit is contained in:
@@ -6,6 +6,7 @@ use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Services\LegacyService;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class ArtController extends Controller
|
||||
{
|
||||
@@ -18,29 +19,23 @@ class ArtController extends Controller
|
||||
|
||||
public function show(Request $request, $id, $slug = null)
|
||||
{
|
||||
// canonicalize to new artwork route when possible
|
||||
// Keep this controller for legacy comment posting and fallback only.
|
||||
// Canonical artwork page rendering is handled by ArtworkPageController.
|
||||
try {
|
||||
$art = \App\Models\Artwork::find((int)$id);
|
||||
if ($art && !empty($art->slug)) {
|
||||
if ($slug !== $art->slug) {
|
||||
// attempt to derive contentType and category for route
|
||||
$category = $art->categories()->with('contentType')->first();
|
||||
if ($category && $category->contentType) {
|
||||
$contentTypeSlug = $category->contentType->slug ?? 'other';
|
||||
$categoryPath = $category->slug ?? $category->category_name ?? 'other';
|
||||
return redirect(route('artworks.show', [
|
||||
'contentTypeSlug' => $contentTypeSlug,
|
||||
'categoryPath' => $categoryPath,
|
||||
'artwork' => $art->slug,
|
||||
]), 301);
|
||||
} elseif (!empty($art->slug)) {
|
||||
// fallback: redirect to artwork slug only (may be handled by router)
|
||||
return redirect('/' . $art->slug, 301);
|
||||
}
|
||||
$art = \App\Models\Artwork::find((int) $id);
|
||||
if ($art && $request->isMethod('get')) {
|
||||
$canonicalSlug = Str::slug((string) ($art->slug ?: $art->title));
|
||||
if ($canonicalSlug === '') {
|
||||
$canonicalSlug = (string) $art->id;
|
||||
}
|
||||
|
||||
return redirect()->route('art.show', [
|
||||
'id' => (int) $art->id,
|
||||
'slug' => $canonicalSlug,
|
||||
], 301);
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
// ignore and continue rendering legacy view
|
||||
// keep legacy fallback below
|
||||
}
|
||||
if ($request->isMethod('post') && $request->input('action') === 'store_comment') {
|
||||
if (auth()->check()) {
|
||||
|
||||
Reference in New Issue
Block a user