3
3
namespace App \Http \Controllers ;
4
4
5
5
use App \Models \FindMoreLikeThis ;
6
- use App \Models \Stubs ;
7
6
use App \Models \Promopage ;
7
+ use App \Models \Stubs ;
8
8
use Illuminate \Contracts \View \View ;
9
9
use Illuminate \Http \Response ;
10
10
use Psr \SimpleCache \InvalidArgumentException ;
@@ -27,16 +27,16 @@ public static function injectPages(string $section = '', string $slug = ''): arr
27
27
* @return View|Response
28
28
* @throws InvalidArgumentException
29
29
*/
30
- public function index (string $ section , string $ slug ): View | Response
30
+ public function index (string $ section , string $ slug ): View | Response
31
31
{
32
32
$ page = Stubs::getPage ($ section , $ slug );
33
33
if (empty ($ page ['data ' ])) {
34
34
return response ()->view ('errors.404 ' , [], 404 );
35
35
} else {
36
36
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
+ ]
40
40
);
41
41
}
42
42
}
@@ -45,31 +45,27 @@ public function index(string $section, string $slug): View|Response
45
45
* @param string $section
46
46
* @return View|Response
47
47
*/
48
- public function landing (string $ section ): View | Response
48
+ public function landing (string $ section ): View | Response
49
49
{
50
50
$ page = Stubs::getLanding ($ section );
51
- if (empty ($ page ['data ' ])) {
51
+ $ promoPage = Promopage::getSubpage ($ section );
52
+
53
+ if (empty ($ page ['data ' ]) && empty ($ promoPage ['data ' ])) {
52
54
return response ()->view ('errors.404 ' , [], 404 );
53
- } else {
55
+ }
56
+
57
+ if (!empty ($ page ['data ' ])) {
54
58
return view ('pages.landing ' , [
55
59
'page ' => Collect ($ page ['data ' ])->first (),
56
- 'associated ' => Stubs::getAssociated ($ section )
60
+ 'associated ' => Stubs::getAssociated ($ section ),
57
61
]);
58
62
}
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 ' ])) {
70
65
return view ('promopage.subpage ' , [
71
- 'page ' => collect ($ promoPage ['data ' ])->first (),
66
+ 'page ' => Collect ($ promoPage ['data ' ])->first (),
72
67
]);
73
68
}
69
+
74
70
}
75
71
}
0 commit comments