prepared and gallery fixes
This commit is contained in:
@@ -4,10 +4,10 @@ namespace App\Http\Controllers\Web;
|
||||
|
||||
use App\Models\Category;
|
||||
use App\Models\ContentType;
|
||||
use App\Models\Artwork;
|
||||
use App\Services\ArtworkService;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Collection;
|
||||
use App\Http\Controllers\ArtworkController as ArtworkControllerAlias;
|
||||
|
||||
class BrowseGalleryController extends \App\Http\Controllers\Controller
|
||||
{
|
||||
@@ -120,13 +120,32 @@ class BrowseGalleryController extends \App\Http\Controllers\Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function showArtwork(Request $request, string $contentTypeSlug, string $categoryPath, string $artwork)
|
||||
public function showArtwork(...$params)
|
||||
{
|
||||
return app(\App\Http\Controllers\ArtController::class)->show(
|
||||
$request,
|
||||
strtolower($contentTypeSlug),
|
||||
trim($categoryPath, '/'),
|
||||
$artwork
|
||||
$req = request();
|
||||
$pathSegments = array_values(array_filter(explode('/', trim($req->path(), '/'))));
|
||||
|
||||
$contentTypeSlug = $params[0] ?? ($pathSegments[0] ?? null);
|
||||
$categoryPath = $params[1] ?? null;
|
||||
$artwork = $params[2] ?? null;
|
||||
|
||||
// If artwork wasn't provided (some route invocations supply fewer args),
|
||||
// derive it from the request path's last segment.
|
||||
if ($artwork === null) {
|
||||
$artwork = end($pathSegments) ?: null;
|
||||
}
|
||||
|
||||
$contentTypeSlug = strtolower((string) $contentTypeSlug);
|
||||
$categoryPath = $categoryPath !== null ? trim((string) $categoryPath, '/') : (isset($pathSegments[1]) ? implode('/', array_slice($pathSegments, 1, max(0, count($pathSegments) - 2))) : '');
|
||||
|
||||
// Normalize artwork param if route-model binding returned an Artwork model
|
||||
$artworkSlug = $artwork instanceof Artwork ? (string) $artwork->slug : (string) $artwork;
|
||||
|
||||
return app(\App\Http\Controllers\ArtworkController::class)->show(
|
||||
$req,
|
||||
$contentTypeSlug,
|
||||
$categoryPath,
|
||||
$artworkSlug
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user