From bd4cfaafe1b5b36f643110918dd163a7338adc2b Mon Sep 17 00:00:00 2001 From: Timothy J Warren Date: Mon, 29 Oct 2018 15:17:48 -0400 Subject: [PATCH] Add staff section on Manga detail pages --- app/views/manga/details.php | 35 +++++++++++++++++++++++++++++++++++ src/Controller/Character.php | 2 -- src/Controller/Manga.php | 32 ++++++++++++++------------------ 3 files changed, 49 insertions(+), 20 deletions(-) diff --git a/app/views/manga/details.php b/app/views/manga/details.php index 3dca28d8..4befe779 100644 --- a/app/views/manga/details.php +++ b/app/views/manga/details.php @@ -73,4 +73,39 @@ + + 0): ?> +
+
+

Staff

+ + $people): ?> +

+
+ $person): ?> + + +
+ + \ No newline at end of file diff --git a/src/Controller/Character.php b/src/Controller/Character.php index 209253f6..0ced1dd2 100644 --- a/src/Controller/Character.php +++ b/src/Controller/Character.php @@ -16,8 +16,6 @@ namespace Aviat\AnimeClient\Controller; -use function Aviat\AnimeClient\getLocalImg; - use Aviat\AnimeClient\Controller as BaseController; use Aviat\AnimeClient\API\JsonAPI; use Aviat\Ion\ArrayWrapper; diff --git a/src/Controller/Manga.php b/src/Controller/Manga.php index cabb2257..9c9a7578 100644 --- a/src/Controller/Manga.php +++ b/src/Controller/Manga.php @@ -294,8 +294,6 @@ final class Manga extends Controller { return; } - // dd($data['included']); - if (array_key_exists('mediaCharacters', $data['included'])) { $mediaCharacters = $data['included']['mediaCharacters']; @@ -318,25 +316,23 @@ final class Manga extends Controller { if (array_key_exists('mediaStaff', $data['included'])) { - foreach ($data['included']['mediaStaff'] as $id => $person) + foreach ($data['included']['mediaStaff'] as $id => $staffing) { - $personDetails = []; - foreach ($person['relationships']['person']['people'] as $p) + $role = $staffing['attributes']['role']; + + foreach($staffing['relationships']['person']['people'] as $personId => $personDetails) { - $personDetails = $p['attributes']; + if ( ! array_key_exists($role, $staff)) + { + $staff[$role] = []; + } + + $staff[$role][$personId] = [ + 'id' => $personId, + 'name' => $personDetails['attributes']['name'] ?? '??', + 'image' => $personDetails['attributes']['image'], + ]; } - - $role = $person['attributes']['role']; - - if ( ! array_key_exists($role, $staff)) - { - $staff[$role] = []; - } - - $staff[$role][$id] = [ - 'name' => $personDetails['name'] ?? '??', - 'image' => $personDetails['image'], - ]; } }