getSearchAssociationQuery example

$query = parent::getDetailQuery($id);
        $query->addSelect(['PARTIAL article.{id, name}']);
        $query->addSelect('shop');
        $query->leftJoin('vote.article', 'article');
        $query->leftJoin('vote.shop', 'shop');

        return $query;
    }

    protected function getSearchAssociationQuery($association$model$search)
    {
        $query = parent::getSearchAssociationQuery($association$model$search);

        if ($association == 'article') {
            $query->innerJoin('article.votes', 'votes');
            $query->groupBy('article.id');
        }

        return $query;
    }

    /** * @param array{success: true, data: array<array<string, mixed>>, total: int} $list * @param array<int, array<string, mixed>> $shops indexed by id * * @return array{success: true, data: array<array<string, mixed>>, total: int} */

    public function searchAssociation($search$association$offset$limit$id = null, $filter = []$sort = [])
    {
        $associationModel = $this->getAssociatedModelByProperty($this->model, $association);

        $builder = $this->getSearchAssociationQuery(
            $association,
            $associationModel,
            $search
        );

        $filter = $this->getFilterConditions(
            $filter,
            $associationModel,
            $association
        );

        
Home | Imprint | This part of the site doesn't use cookies.