public function getDecisions($size = null, $table_id = null, $variant_id = null) { /** @var \Jenssegers\Mongodb\Eloquent\Builder $query */ if ($table_id) { $query = $this->getModel()->query()->where('table._id', $table_id); if ($query->count() <= 0) { $e = new ModelNotFoundException(); $e->setModel(Decision::class); throw $e; } $query = $query->orderBy(Decision::CREATED_AT, 'DESC'); } elseif ($variant_id) { $query = $this->getModel()->query()->where('table.variant._id', $variant_id); } else { $query = Decision::orderBy(Decision::CREATED_AT, 'DESC'); } $query = $query->where('applications', ApplicationableHelper::getApplicationId()); return $this->paginateQuery($query, $size); }