update datatable

This commit is contained in:
pbao9
2026-01-30 13:56:32 +07:00
parent 9802839056
commit cfe38232c3
10 changed files with 292 additions and 215 deletions
@@ -12,22 +12,39 @@ class DatacenterRepository extends BaseRepository implements DatacenterRepositor
return ModuleDatacenter::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
->select($select)
->with($relationships);
if (isset($data['vcenter_id']) && $data['vcenter_id']) {
$model = $model->where("vcenter_id", $data['vcenter_id']);
if (!empty($data['vcenter_id'])) {
$query->where('vcenter_id', $data['vcenter_id']);
}
if (count($withCount) > 0) {
$model = $model->withCount($withCount);
if (!empty($withCount)) {
$query->withCount($withCount);
}
if (isset($data['page'])) {
return $model->paginate(15);
if ($returnQuery) {
return $query;
}
return $model->get();
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)) {