From 62ec058942431b099843d9225ff348f6ac290951 Mon Sep 17 00:00:00 2001 From: Mekaeil Date: Sat, 18 May 2024 19:56:38 +0200 Subject: [PATCH] fix: group seeder command --- README.md | 7 +++++-- src/Core/User/Repository/GroupRepositoryInterface.php | 2 +- .../User/Repository/Eloquent/GroupEloquentRepository.php | 9 ++++++--- .../User/Seeders/Group/MasterGroupTableSeeder.php | 2 +- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index b686d59..5dc901f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,9 @@ -![image](https://github.com/weprodev/LaraPanel/blob/master/src/Presentation/Panel/Stub/Public/logo.png) +

LaraPanel Logo

-License +

+Latest Stable Version +License +

# About LaraPanel diff --git a/src/Core/User/Repository/GroupRepositoryInterface.php b/src/Core/User/Repository/GroupRepositoryInterface.php index b8cdcae..1dca5ab 100644 --- a/src/Core/User/Repository/GroupRepositoryInterface.php +++ b/src/Core/User/Repository/GroupRepositoryInterface.php @@ -27,7 +27,7 @@ public function pluckAll(): Collection; public function findById(int $groupId): GroupDomain; - public function findBy(array $attributes): GroupDomain; + public function findBy(array $attributes): ?GroupDomain; public function delete(int $groupId): void; diff --git a/src/Infrastructure/User/Repository/Eloquent/GroupEloquentRepository.php b/src/Infrastructure/User/Repository/Eloquent/GroupEloquentRepository.php index 3c6aac5..b49c045 100644 --- a/src/Infrastructure/User/Repository/Eloquent/GroupEloquentRepository.php +++ b/src/Infrastructure/User/Repository/Eloquent/GroupEloquentRepository.php @@ -99,11 +99,14 @@ public function findById(int $groupId): GroupDomain return GroupFactory::fromEloquent($groupModel); } - public function findBy(array $attributes): GroupDomain + public function findBy(array $attributes): ?GroupDomain { - $groupModel = Group::where($attributes)->firstOrFail(); + if ($groupModel = Group::where($attributes)->first()) { - return GroupFactory::fromEloquent($groupModel); + return GroupFactory::fromEloquent($groupModel); + } + + return null; } public function delete(int $groupId): void diff --git a/src/Infrastructure/User/Seeders/Group/MasterGroupTableSeeder.php b/src/Infrastructure/User/Seeders/Group/MasterGroupTableSeeder.php index 4d6146e..d03eef1 100644 --- a/src/Infrastructure/User/Seeders/Group/MasterGroupTableSeeder.php +++ b/src/Infrastructure/User/Seeders/Group/MasterGroupTableSeeder.php @@ -33,7 +33,7 @@ public function run(): void if ($item['parent'] != null) { $parent = $this->groupRepositoryInterface->findBy([ 'name' => $item['name'], - ])->getId(); + ])?->getId(); } $findGroup = $this->groupRepositoryInterface->findBy([