model ->select($select) ->with($relationships); if (!empty($data['vcenter_id'])) { $query->where('vcenter_id', $data['vcenter_id']); } if (!empty($withCount)) { $query->withCount($withCount); } if ($returnQuery) { return $query; } if (!empty($data['paginate'])) { return $query->paginate( $data['per_page'] ?? 15 ); } return $query->get(); } public function findBy(string $key = '', string|int|null $value = '') { if (empty($key) || empty($value)) { return false; } return $this->model->where($key, $value)->first(); } }