feat: Implement new admin API endpoints for product, customer, vCenter, and authentication, and add vCenter resource management UI.
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories\Admin\Customer;
|
||||
|
||||
use App\Models\Customer;
|
||||
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
||||
|
||||
class AdminCustomerRepository implements AdminCustomerRepositoryInterface
|
||||
{
|
||||
private const STATUS_MAP = [
|
||||
'active' => 1,
|
||||
'inactive' => 2,
|
||||
'pending' => 0,
|
||||
'suspended' => 3,
|
||||
];
|
||||
|
||||
public function paginate(array $filters, int $perPage): LengthAwarePaginator
|
||||
{
|
||||
$query = Customer::query()->orderBy('id', 'desc');
|
||||
|
||||
if ($filter = $filters['filter'] ?? null) {
|
||||
$query->where(function ($q) use ($filter) {
|
||||
$q->where('fullname', 'like', "%{$filter}%")
|
||||
->orWhere('email', 'like', "%{$filter}%")
|
||||
->orWhere('phone', 'like', "%{$filter}%");
|
||||
});
|
||||
}
|
||||
|
||||
if ($status = $filters['status'] ?? null) {
|
||||
$statusInt = self::STATUS_MAP[$status] ?? null;
|
||||
if ($statusInt !== null) {
|
||||
$query->where('status', $statusInt);
|
||||
}
|
||||
}
|
||||
|
||||
return $query->paginate($perPage);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user