update fix deadcode, security
This commit is contained in:
@@ -26,11 +26,6 @@ abstract class BaseApiRepository implements BaseRepositoryInterface
|
||||
return $this->model->create($data);
|
||||
}
|
||||
|
||||
public function getAll()
|
||||
{
|
||||
return $this->model->all();
|
||||
}
|
||||
|
||||
public function find($id)
|
||||
{
|
||||
return $this->model->find($id);
|
||||
@@ -63,9 +58,4 @@ abstract class BaseApiRepository implements BaseRepositoryInterface
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getCount()
|
||||
{
|
||||
return $this->model->count('id');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,12 +11,4 @@ class ClientRepository extends BaseApiRepository implements ClientRepositoryInte
|
||||
{
|
||||
return Customer::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tìm khách hàng theo email
|
||||
*/
|
||||
public function findByEmail(string $email)
|
||||
{
|
||||
return $this->model->where('email', $email)->first();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,8 +6,4 @@ use App\Repositories\BaseRepositoryInterface;
|
||||
|
||||
interface ClientRepositoryInterface extends BaseRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* Tìm khách hàng theo email
|
||||
*/
|
||||
public function findByEmail(string $email);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ use App\Models\Invoice;
|
||||
use App\Models\InvoiceItem;
|
||||
use App\Models\Order;
|
||||
use App\Repositories\Api\BaseApiRepository;
|
||||
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
||||
|
||||
class InvoiceRepository extends BaseApiRepository implements InvoiceRepositoryInterface
|
||||
{
|
||||
@@ -17,18 +16,6 @@ class InvoiceRepository extends BaseApiRepository implements InvoiceRepositoryIn
|
||||
return Invoice::class;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// getInvoice
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
public function getInvoice(int $limit = 10, int $customerId = 0): LengthAwarePaginator
|
||||
{
|
||||
return $this->model
|
||||
->where('customer_id', $customerId)
|
||||
->orderByDesc('created_at')
|
||||
->paginate($limit);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// createFromOrder
|
||||
// -------------------------------------------------------------------------
|
||||
@@ -97,5 +84,4 @@ class InvoiceRepository extends BaseApiRepository implements InvoiceRepositoryIn
|
||||
// -------------------------------------------------------------------------
|
||||
// Helpers
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
}
|
||||
|
||||
@@ -5,15 +5,9 @@ namespace App\Repositories\Api\Invoice;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\Order;
|
||||
use App\Repositories\BaseRepositoryInterface;
|
||||
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
||||
|
||||
interface InvoiceRepositoryInterface extends BaseRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* Paginated invoice list for a customer.
|
||||
*/
|
||||
public function getInvoice(int $limit, int $customerId): LengthAwarePaginator;
|
||||
|
||||
/**
|
||||
* Create an invoice (+ invoice_items) from a completed Order.
|
||||
*/
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Repositories\Api\Order;
|
||||
|
||||
use App\Enums\Invoice\InvoiceStatus;
|
||||
use App\Enums\Order\OrderStatus;
|
||||
use App\Models\Order;
|
||||
use App\Models\OrderItem;
|
||||
@@ -30,28 +29,6 @@ class OrderRepository extends BaseApiRepository implements OrderRepositoryInterf
|
||||
);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// processPayment
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
public function processPayment(Order $order, string $method): Order
|
||||
{
|
||||
$order->update([
|
||||
'status' => OrderStatus::ACTIVE->value,
|
||||
'payment_method' => $method,
|
||||
]);
|
||||
|
||||
if ($order->invoice) {
|
||||
$order->invoice->update([
|
||||
'status' => InvoiceStatus::PAID->value,
|
||||
'payment_method' => $method,
|
||||
'paid_at' => now(),
|
||||
]);
|
||||
}
|
||||
|
||||
return $order->fresh(['orderItems', 'invoice', 'customer']);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// hasPendingOrder
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@@ -15,11 +15,6 @@ interface OrderRepositoryInterface extends BaseRepositoryInterface
|
||||
*/
|
||||
public function createItem(int $orderId, array $data): OrderItem;
|
||||
|
||||
/**
|
||||
* Mark order as completed, update the related invoice as paid.
|
||||
*/
|
||||
public function processPayment(Order $order, string $method): Order;
|
||||
|
||||
/**
|
||||
* Return true if the customer has any pending orders.
|
||||
*/
|
||||
@@ -34,4 +29,6 @@ interface OrderRepositoryInterface extends BaseRepositoryInterface
|
||||
* Find an order by order_num, scoped to the owning customer.
|
||||
*/
|
||||
public function findByOrderNum(string $orderNum, int $customerId): ?Order;
|
||||
|
||||
public function findForCustomer(int $id, int $customerId): ?Order;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user