update
This commit is contained in:
@@ -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 = [])
|
||||
|
||||
Reference in New Issue
Block a user