udpate
This commit is contained in:
@@ -11,34 +11,36 @@ class OsRepository extends BaseRepository implements OsRepositoryInterface
|
||||
{
|
||||
return Os::class;
|
||||
}
|
||||
public function filter(array $data = [], array $relationships = [], array $withCount = [], array $select = ['*'])
|
||||
{
|
||||
$model = $this->model->with($relationships)->select($select);
|
||||
|
||||
// Apply filters from $data
|
||||
if (isset($data['os_id'])) {
|
||||
$model = $model->where('os_group_id', $data['os_id']);
|
||||
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 (isset($data['os_group_id'])) {
|
||||
$model = $model->where('os_group_id', $data['os_group_id']);
|
||||
|
||||
if (!empty($withCount)) {
|
||||
$query->withCount($withCount);
|
||||
}
|
||||
|
||||
if (isset($data['module_host_id'])) {
|
||||
$model = $model->where('module_host_id', $data['module_host_id']);
|
||||
|
||||
if ($returnQuery) {
|
||||
return $query;
|
||||
}
|
||||
|
||||
if (isset($data['status'])) {
|
||||
$model = $model->where('status', $data['status']);
|
||||
|
||||
if (!empty($data['paginate'])) {
|
||||
return $query->paginate(
|
||||
$data['per_page'] ?? 15
|
||||
);
|
||||
}
|
||||
|
||||
if (count($withCount) > 0) {
|
||||
$model = $model->withCount($withCount);
|
||||
}
|
||||
if(isset($data['page'])) {
|
||||
return $model->paginate(15);
|
||||
}
|
||||
return $model->get();
|
||||
|
||||
return $query->get();
|
||||
}
|
||||
public function findWithRelationships(int $id = 0, array $relationships = [], array $withCount = [], array $withSum = [])
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user