Skip to content

Commit d711fd4

Browse files
authored
Merge pull request #710 from FitzwilliamMuseum/hotfix/promo-page-route
Hotfix/promo page route
2 parents f442e4c + ba51d27 commit d711fd4

File tree

2 files changed

+18
-23
lines changed

2 files changed

+18
-23
lines changed

app/Http/Controllers/pagesController.php

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
namespace App\Http\Controllers;
44

55
use App\Models\FindMoreLikeThis;
6-
use App\Models\Stubs;
76
use App\Models\Promopage;
7+
use App\Models\Stubs;
88
use Illuminate\Contracts\View\View;
99
use Illuminate\Http\Response;
1010
use Psr\SimpleCache\InvalidArgumentException;
@@ -27,16 +27,16 @@ public static function injectPages(string $section = '', string $slug = ''): arr
2727
* @return View|Response
2828
* @throws InvalidArgumentException
2929
*/
30-
public function index(string $section, string $slug): View|Response
30+
public function index(string $section, string $slug): View | Response
3131
{
3232
$page = Stubs::getPage($section, $slug);
3333
if (empty($page['data'])) {
3434
return response()->view('errors.404', [], 404);
3535
} else {
3636
return view('pages.index', [
37-
'page' => Collect($page['data'])->first(),
38-
'records' => FindMoreLikeThis::find($slug, 'pages'),
39-
]
37+
'page' => Collect($page['data'])->first(),
38+
'records' => FindMoreLikeThis::find($slug, 'pages'),
39+
]
4040
);
4141
}
4242
}
@@ -45,31 +45,27 @@ public function index(string $section, string $slug): View|Response
4545
* @param string $section
4646
* @return View|Response
4747
*/
48-
public function landing(string $section): View|Response
48+
public function landing(string $section): View | Response
4949
{
5050
$page = Stubs::getLanding($section);
51-
if (empty($page['data'])) {
51+
$promoPage = Promopage::getSubpage($section);
52+
53+
if (empty($page['data']) && empty($promoPage['data'])) {
5254
return response()->view('errors.404', [], 404);
53-
} else {
55+
}
56+
57+
if (!empty($page['data'])) {
5458
return view('pages.landing', [
5559
'page' => Collect($page['data'])->first(),
56-
'associated' => Stubs::getAssociated($section)
60+
'associated' => Stubs::getAssociated($section),
5761
]);
5862
}
59-
}
60-
/**
61-
* @param string $section
62-
* @return View|Response
63-
*/
64-
public function promo(string $section): View|Response
65-
{
66-
$promoPage = Promopage::getSubpage($section);
67-
if (empty($promoPage['data'])) {
68-
return response()->view('errors.404', [], 404);
69-
} else {
63+
64+
if (!empty($promoPage['data'])) {
7065
return view('promopage.subpage', [
71-
'page' => collect($promoPage['data'])->first(),
66+
'page' => Collect($promoPage['data'])->first(),
7267
]);
7368
}
69+
7470
}
7571
}

routes/web.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,5 @@
207207
/*
208208
* Catch all route
209209
*/
210-
Route::get('/{slug}', 'pagesController@promo')->name('promo');
211-
Route::get('/{section}/{slug}/', 'pagesController@index')->name('landing-section');
212210
Route::get('/{section}', 'pagesController@landing')->name('landing');
211+
Route::get('/{section}/{slug}/', 'pagesController@index')->name('landing-section');

0 commit comments

Comments
 (0)