Added repositories
This commit is contained in:
parent
283953d64d
commit
efaf634867
35
app/Providers/RepositoryServiceProvider.php
Normal file
35
app/Providers/RepositoryServiceProvider.php
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use App\Repositories\Interfaces\CarRepositoryInterface;
|
||||||
|
use App\Repositories\Interfaces\DeliveryRepositoryInterface;
|
||||||
|
use App\Repositories\Interfaces\UserRepositoryInterface;
|
||||||
|
use App\Repositories\Interfaces\WarehouseRepositoryInterface;
|
||||||
|
use App\Repositories\SQL\CarRepository;
|
||||||
|
use App\Repositories\SQL\DeliveryRepository;
|
||||||
|
use App\Repositories\SQL\UserRepository;
|
||||||
|
use App\Repositories\SQL\WarehouseRepository;
|
||||||
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
|
class RepositoryServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Register services.
|
||||||
|
*/
|
||||||
|
public function register(): void
|
||||||
|
{
|
||||||
|
$this->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
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
13
app/Repositories/Interfaces/CarRepositoryInterface.php
Normal file
13
app/Repositories/Interfaces/CarRepositoryInterface.php
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Repositories\Interfaces;
|
||||||
|
|
||||||
|
use App\Models\Car;
|
||||||
|
|
||||||
|
interface CarRepositoryInterface
|
||||||
|
{
|
||||||
|
public function getAllCars();
|
||||||
|
public function createCar(array $data);
|
||||||
|
public function updateCar(Car $car, array $data);
|
||||||
|
public function deleteCar(Car $car);
|
||||||
|
}
|
13
app/Repositories/Interfaces/DeliveryRepositoryInterface.php
Normal file
13
app/Repositories/Interfaces/DeliveryRepositoryInterface.php
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Repositories\Interfaces;
|
||||||
|
|
||||||
|
use App\Models\Delivery;
|
||||||
|
|
||||||
|
interface DeliveryRepositoryInterface
|
||||||
|
{
|
||||||
|
public function getAllDeliveries();
|
||||||
|
public function createDelivery(array $data);
|
||||||
|
public function updateDelivery(Delivery $delivery, array $data);
|
||||||
|
public function deleteDelivery(Delivery $delivery);
|
||||||
|
}
|
14
app/Repositories/Interfaces/UserRepositoryInterface.php
Normal file
14
app/Repositories/Interfaces/UserRepositoryInterface.php
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Repositories\Interfaces;
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
|
|
||||||
|
interface UserRepositoryInterface
|
||||||
|
{
|
||||||
|
public function getAllUsers();
|
||||||
|
public function createUser(array $data);
|
||||||
|
public function updateUser(User $user, array $data);
|
||||||
|
public function deleteUser(User $user);
|
||||||
|
|
||||||
|
}
|
13
app/Repositories/Interfaces/WarehouseRepositoryInterface.php
Normal file
13
app/Repositories/Interfaces/WarehouseRepositoryInterface.php
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Repositories\Interfaces;
|
||||||
|
|
||||||
|
use App\Models\Warehouse;
|
||||||
|
|
||||||
|
interface WarehouseRepositoryInterface
|
||||||
|
{
|
||||||
|
public function getAllWarehouses();
|
||||||
|
public function createWarehouse(array $data);
|
||||||
|
public function updateWarehouse(Warehouse $warehouse, array $data);
|
||||||
|
public function deleteWarehouse(Warehouse $warehouse);
|
||||||
|
}
|
30
app/Repositories/SQL/CarRepository.php
Normal file
30
app/Repositories/SQL/CarRepository.php
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Repositories\SQL;
|
||||||
|
|
||||||
|
use App\Models\Car;
|
||||||
|
use App\Repositories\Interfaces\CarRepositoryInterface;
|
||||||
|
|
||||||
|
class CarRepository implements CarRepositoryInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
public function getAllCars()
|
||||||
|
{
|
||||||
|
return Car::paginate(5)->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();
|
||||||
|
}
|
||||||
|
}
|
30
app/Repositories/SQL/DeliveryRepository.php
Normal file
30
app/Repositories/SQL/DeliveryRepository.php
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Repositories\SQL;
|
||||||
|
|
||||||
|
use App\Models\Delivery;
|
||||||
|
use App\Repositories\Interfaces\DeliveryRepositoryInterface;
|
||||||
|
|
||||||
|
class DeliveryRepository implements DeliveryRepositoryInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
public function getAllDeliveries()
|
||||||
|
{
|
||||||
|
return Delivery::paginate(5)->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();
|
||||||
|
}
|
||||||
|
}
|
29
app/Repositories/SQL/UserRepository.php
Normal file
29
app/Repositories/SQL/UserRepository.php
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Repositories\SQL;
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Repositories\Interfaces\UserRepositoryInterface;
|
||||||
|
|
||||||
|
class UserRepository implements UserRepositoryInterface
|
||||||
|
{
|
||||||
|
public function getAllUsers()
|
||||||
|
{
|
||||||
|
return User::paginate(5)->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();
|
||||||
|
}
|
||||||
|
}
|
29
app/Repositories/SQL/WarehouseRepository.php
Normal file
29
app/Repositories/SQL/WarehouseRepository.php
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Repositories\SQL;
|
||||||
|
|
||||||
|
use App\Models\Warehouse;
|
||||||
|
use App\Repositories\Interfaces\WarehouseRepositoryInterface;
|
||||||
|
|
||||||
|
class WarehouseRepository implements WarehouseRepositoryInterface
|
||||||
|
{
|
||||||
|
public function getAllWarehouses()
|
||||||
|
{
|
||||||
|
return Warehouse::paginate(5)->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();
|
||||||
|
}
|
||||||
|
}
|
@ -168,6 +168,7 @@ return [
|
|||||||
// App\Providers\BroadcastServiceProvider::class,
|
// App\Providers\BroadcastServiceProvider::class,
|
||||||
App\Providers\EventServiceProvider::class,
|
App\Providers\EventServiceProvider::class,
|
||||||
App\Providers\RouteServiceProvider::class,
|
App\Providers\RouteServiceProvider::class,
|
||||||
|
App\Providers\RepositoryServiceProvider::class,
|
||||||
])->toArray(),
|
])->toArray(),
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user