|
|
@@ -11,11 +11,16 @@ use Illuminate\Support\Facades\Hash;
|
|
|
|
|
|
class PartnerAgreementService
|
|
|
{
|
|
|
- public function getAll(): Collection
|
|
|
+ public function getAll(array $filters = []): Collection
|
|
|
{
|
|
|
- return PartnerAgreement::with(['category', 'city', 'logo'])
|
|
|
- ->orderBy('company_name')
|
|
|
- ->get();
|
|
|
+ $query = PartnerAgreement::with(['category', 'city', 'logo'])
|
|
|
+ ->orderBy('company_name');
|
|
|
+
|
|
|
+ if (!empty($filters['type'])) {
|
|
|
+ $query->where('type', $filters['type']);
|
|
|
+ }
|
|
|
+
|
|
|
+ return $query->get();
|
|
|
}
|
|
|
|
|
|
public function getAllPaginated(array $filters = [], int $perPage = 10): LengthAwarePaginator
|
|
|
@@ -23,6 +28,10 @@ class PartnerAgreementService
|
|
|
$query = PartnerAgreement::with(['category', 'city', 'logo'])
|
|
|
->orderBy('company_name');
|
|
|
|
|
|
+ if (!empty($filters['type'])) {
|
|
|
+ $query->where('type', $filters['type']);
|
|
|
+ }
|
|
|
+
|
|
|
if (!empty($filters['search'])) {
|
|
|
$search = $filters['search'];
|
|
|
$query->where(function ($q) use ($search) {
|