repository pattern
This commit is contained in:
39
app/Repositories/OrderRepository.php
Normal file
39
app/Repositories/OrderRepository.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
use App\Interfaces\OrderRepositoryInterface;
|
||||
use App\Models\Order;
|
||||
|
||||
class OrderRepository implements OrderRepositoryInterface
|
||||
{
|
||||
public function getAllOrders()
|
||||
{
|
||||
return Order::all();
|
||||
}
|
||||
|
||||
public function getOrderById($orderId)
|
||||
{
|
||||
return Order::findOrFail($orderId);
|
||||
}
|
||||
|
||||
public function deleteOrder($orderId)
|
||||
{
|
||||
Order::destroy($orderId);
|
||||
}
|
||||
|
||||
public function createOrder(array $orderDetails)
|
||||
{
|
||||
return Order::create($orderDetails);
|
||||
}
|
||||
|
||||
public function updateOrder($orderId, array $newDetails)
|
||||
{
|
||||
return Order::whereId($orderId)->update($newDetails);
|
||||
}
|
||||
|
||||
public function getFulfilledOrders()
|
||||
{
|
||||
return Order::where('is_fulfilled', true);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user