From a7d1a19d6d1ab92b2b33b2d634ddc895336a817f Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Wed, 8 Mar 2023 11:57:37 +0100 Subject: [PATCH] Update PostAuthor::all() to map entries into array keyed by username Otherwise `static::all()->firstWhere('username', $username)` doesn't work. --- .../src/Framework/Features/Blogging/Models/PostAuthor.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/framework/src/Framework/Features/Blogging/Models/PostAuthor.php b/packages/framework/src/Framework/Features/Blogging/Models/PostAuthor.php index e4886181eb1..ec6b25cad15 100644 --- a/packages/framework/src/Framework/Features/Blogging/Models/PostAuthor.php +++ b/packages/framework/src/Framework/Features/Blogging/Models/PostAuthor.php @@ -71,7 +71,9 @@ public static function get(string $username): static /** @return \Illuminate\Support\Collection<\Hyde\Framework\Features\Blogging\Models\PostAuthor> */ public static function all(): Collection { - return new Collection(Config::getArray('hyde.authors', [])); + return (new Collection(Config::getArray('hyde.authors', [])))->mapWithKeys(function (self $author): array { + return [$author->username => $author]; + }); } public function __toString(): string