From efaf6348679c735b5cab3df11c3b26306c404d87 Mon Sep 17 00:00:00 2001 From: "m.zargarov" Date: Wed, 10 Jan 2024 12:56:02 +0400 Subject: [PATCH] Added repositories --- app/Providers/RepositoryServiceProvider.php | 35 +++++++++++++++++++ .../Interfaces/CarRepositoryInterface.php | 13 +++++++ .../DeliveryRepositoryInterface.php | 13 +++++++ .../Interfaces/UserRepositoryInterface.php | 14 ++++++++ .../WarehouseRepositoryInterface.php | 13 +++++++ app/Repositories/SQL/CarRepository.php | 30 ++++++++++++++++ app/Repositories/SQL/DeliveryRepository.php | 30 ++++++++++++++++ app/Repositories/SQL/UserRepository.php | 29 +++++++++++++++ app/Repositories/SQL/WarehouseRepository.php | 29 +++++++++++++++ config/app.php | 1 + 10 files changed, 207 insertions(+) create mode 100644 app/Providers/RepositoryServiceProvider.php create mode 100644 app/Repositories/Interfaces/CarRepositoryInterface.php create mode 100644 app/Repositories/Interfaces/DeliveryRepositoryInterface.php create mode 100644 app/Repositories/Interfaces/UserRepositoryInterface.php create mode 100644 app/Repositories/Interfaces/WarehouseRepositoryInterface.php create mode 100644 app/Repositories/SQL/CarRepository.php create mode 100644 app/Repositories/SQL/DeliveryRepository.php create mode 100644 app/Repositories/SQL/UserRepository.php create mode 100644 app/Repositories/SQL/WarehouseRepository.php diff --git a/app/Providers/RepositoryServiceProvider.php b/app/Providers/RepositoryServiceProvider.php new file mode 100644 index 0000000..82e82a5 --- /dev/null +++ b/app/Providers/RepositoryServiceProvider.php @@ -0,0 +1,35 @@ +app->bind(UserRepositoryInterface::class, UserRepository::class); + $this->app->bind(DeliveryRepositoryInterface::class, DeliveryRepository::class); + $this->app->bind(CarRepositoryInterface::class, CarRepository::class); + $this->app->bind(WarehouseRepositoryInterface::class, WarehouseRepository::class); + } + + /** + * Bootstrap services. + */ + public function boot(): void + { + // + } +} diff --git a/app/Repositories/Interfaces/CarRepositoryInterface.php b/app/Repositories/Interfaces/CarRepositoryInterface.php new file mode 100644 index 0000000..4bc0315 --- /dev/null +++ b/app/Repositories/Interfaces/CarRepositoryInterface.php @@ -0,0 +1,13 @@ +get(); + } + + public function createCar(array $data) + { + Car::create($data); + } + + public function updateCar(Car $car, array $data) + { + $car->update($data); + } + + public function deleteCar(Car $car) + { + $car->delete(); + } +} diff --git a/app/Repositories/SQL/DeliveryRepository.php b/app/Repositories/SQL/DeliveryRepository.php new file mode 100644 index 0000000..32b99f0 --- /dev/null +++ b/app/Repositories/SQL/DeliveryRepository.php @@ -0,0 +1,30 @@ +get(); + } + + public function createDelivery(array $data) + { + Delivery::create($data); + } + + public function updateDelivery(Delivery $delivery, array $data) + { + $delivery->update($data); + } + + public function deleteDelivery(Delivery $delivery) + { + $delivery->delete(); + } +} diff --git a/app/Repositories/SQL/UserRepository.php b/app/Repositories/SQL/UserRepository.php new file mode 100644 index 0000000..5ee5888 --- /dev/null +++ b/app/Repositories/SQL/UserRepository.php @@ -0,0 +1,29 @@ +get(); + } + + public function createUser(array $data) + { + User::create($data); + } + + public function updateUser(User $user, array $data) + { + $user->update($data); + } + + public function deleteUser(User $user) + { + $user->delete(); + } +} diff --git a/app/Repositories/SQL/WarehouseRepository.php b/app/Repositories/SQL/WarehouseRepository.php new file mode 100644 index 0000000..52bff9c --- /dev/null +++ b/app/Repositories/SQL/WarehouseRepository.php @@ -0,0 +1,29 @@ +get(); + } + + public function createWarehouse(array $data) + { + Warehouse::create($data); + } + + public function updateWarehouse(Warehouse $warehouse, array $data) + { + $warehouse->update($data); + } + + public function deleteWarehouse(Warehouse $warehouse) + { + $warehouse->delete(); + } +} diff --git a/config/app.php b/config/app.php index 9207160..ac864d1 100644 --- a/config/app.php +++ b/config/app.php @@ -168,6 +168,7 @@ return [ // App\Providers\BroadcastServiceProvider::class, App\Providers\EventServiceProvider::class, App\Providers\RouteServiceProvider::class, + App\Providers\RepositoryServiceProvider::class, ])->toArray(), /*