This commit is contained in:
pbao9
2026-01-30 17:08:59 +07:00
parent 69923ea016
commit 72b690f22e
15 changed files with 370 additions and 211 deletions
@@ -12,23 +12,32 @@ class HostRepository extends BaseRepository implements HostRepositoryInterface
return ModuleHost::class;
}
public function filter(array $data = [], array $relationships = [], array $withCount = [], array $select = ['*'])
{
$model = $this->model->with($relationships)->select($select);
public function filter(
array $data = [],
array $relationships = [],
array $withCount = [],
array $select = ['*'],
bool $returnQuery = false
) {
$query = $this->model->with($relationships)->select($select);
if (isset($data['module_datacenter_id']) && $data['module_datacenter_id']) {
$model = $model->where("module_datacenter_id", $data['module_datacenter_id']);
$query = $query->where("module_datacenter_id", $data['module_datacenter_id']);
}
if (count($withCount) > 0) {
$model = $model->withCount($withCount);
$query = $query->withCount($withCount);
}
if (isset($data['page'])) {
return $model->paginate(15);
if ($returnQuery) {
return $query;
}
return $model->get();
if (isset($data['page']) || isset($data['paginate'])) {
return $query->paginate($data['per_page'] ?? 15);
}
return $query->get();
}
public function findWithRelationships(int $id = 0, array $relationships = [], array $withCount = [], array $withSum = [])