diff --git a/Changelog b/Changelog index 467b02831..ee3c68a35 100755 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ 2018-11-19 DariusIII + * Chg: Update Console and Details controllers, change behaviour on missing data * Chg: Update ContentController, do not show 404 page on missing content but return json message * Fix: Fix display of contact form when logged in 2018-11-18 DariusIII diff --git a/app/Http/Controllers/ConsoleController.php b/app/Http/Controllers/ConsoleController.php index c0fc3f7ea..f569bb00b 100644 --- a/app/Http/Controllers/ConsoleController.php +++ b/app/Http/Controllers/ConsoleController.php @@ -13,6 +13,7 @@ class ConsoleController extends BasePageController * @param \Illuminate\Http\Request $request * @param string $id * + * @return \Illuminate\Http\JsonResponse * @throws \Exception */ public function show(Request $request, $id = '') @@ -92,7 +93,7 @@ class ConsoleController extends BasePageController if ($cdata !== null) { $this->smarty->assign('catname', $cdata); } else { - $this->show404(); + return response()->json(['message' => 'There are no categories set.'], 404); } } diff --git a/app/Http/Controllers/DetailsController.php b/app/Http/Controllers/DetailsController.php index 6ca2c1e3d..2a58b1291 100644 --- a/app/Http/Controllers/DetailsController.php +++ b/app/Http/Controllers/DetailsController.php @@ -29,6 +29,7 @@ class DetailsController extends BasePageController /** * @param $guid * + * @return \Illuminate\Http\RedirectResponse * @throws \Exception */ public function show($guid) @@ -45,7 +46,7 @@ class DetailsController extends BasePageController $releaseRegex = ReleaseRegex::query()->where('releases_id', '=', $data['id'])->first(); if (! $data) { - $this->show404(); + return redirect()->back(); } if ($this->isPostBack()) { @@ -105,32 +106,27 @@ class DetailsController extends BasePageController $game = ''; if ($data['gamesinfo_id'] !== '') { - $g = new Games(); - $game = $g->getGamesInfoById($data['gamesinfo_id']); + $game = (new Games())->getGamesInfoById($data['gamesinfo_id']); } $mus = ''; if ($data['musicinfo_id'] !== '') { - $music = new Music(['Settings' => $this->settings]); - $mus = $music->getMusicInfo($data['musicinfo_id']); + $mus = (new Music(['Settings' => $this->settings]))->getMusicInfo($data['musicinfo_id']); } $book = ''; if ($data['bookinfo_id'] !== '') { - $b = new Books(); - $book = $b->getBookInfo($data['bookinfo_id']); + $book = (new Books())->getBookInfo($data['bookinfo_id']); } $con = ''; if ($data['consoleinfo_id'] !== '') { - $c = new Console(); - $con = $c->getConsoleInfo($data['consoleinfo_id']); + $con = (new Console())->getConsoleInfo($data['consoleinfo_id']); } $AniDBAPIArray = ''; if ($data['anidbid'] > 0) { - $AniDB = new AniDB(); - $AniDBAPIArray = $AniDB->getAnimeInfo($data['anidbid']); + $AniDBAPIArray = (new AniDB())->getAnimeInfo($data['anidbid']); } $pre = Predb::getForRelease($data['predb_id']);