update os group

This commit is contained in:
pbao9
2026-02-02 09:07:33 +07:00
parent b3ad727d55
commit af71413a69
9 changed files with 182 additions and 106 deletions
+27 -11
View File
@@ -11,20 +11,36 @@ class OsGroupRepository extends BaseRepository implements OsGroupRepositoryInter
{
return OsGroup::class;
}
public function filter(array $data = [], array $relationships = [], array $withCount = [], array $select = ['*'])
{
$model = $this->model->with($relationships)->select($select);
if (isset($data['status'])) {
$model = $model->where("status", $data['status']);
public function filter(
array $data = [],
array $relationships = [],
array $withCount = [],
array $select = ['*'],
bool $returnQuery = false
) {
$query = $this->model
->select($select)
->with($relationships);
if (!empty($data['module_host_id'])) {
$query->where('module_host_id', $data['module_host_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 findWithRelationships(int $id = 0, array $relationships = [], array $withCount = [], array $withSum = [])
{