Для начала рекомендую ознакомиться с документацией по Eloquent на сайте Laravel https://laravel.com/docs/6.x/queries так как в Evo логика работы с базой такая же, это не только удобно но еще и дает возможность находить информацию что и как сделать не только в рамках Evolution CMS.
Спасибо Webber за DLSiteContent, https://github.com/webber12/DLSiteContent основные методы работы с TV так же интегрированны в ядро.
$docs = SiteContent::withTVs(['price', 'titl'])
->active()
->where('parent', 0)
->where('tv_price.value', '>', '150')
->orderBy('tv_price.value', 'desc')
->orderBy('pagetitle', 'asc')
->get();
$docs = SiteContent::withTVs(['price', 'brand'])
->active()
->where('parent', 0)
->tvFilter("tv:price:>:150:UNSIGNED;tv:price:<:600:UNSIGNED;tv:brand:in:а,б,в;tv:brand:!null;")
->tvOrderBy("price asc UNSIGNED, brand asc")
->orderBy('pagetitle', 'asc')
->get();
$docs = SiteContent::withTVs(['price:d', 'brand'])
->active()
->where('parent', 0)
->tvFilter("tvd:price:>:150:UNSIGNED;tv:brand:in:а,б,в")
->tvOrderBy("price:d asc UNSIGNED, brand asc")
->orderBy('pagetitle', 'asc')
->get();
$result = SiteContent::where('parent', 0)
->active()
->get();
$docs = SiteContent::tvList($result, ['price', 'brand']);
$docs = SiteContent::where('parent', 1)
->active()
->tagsData('17:5,7,8')
->orderByDate()
->get();
За основу реализации был взят данный компонент для Laravel https://github.com/franzose/ClosureTable, но интегрирован в ядро.
$docs = SiteContent::GetRootTree(2)
->withTVs(['test'], ':', true)
->get()
->toTree()
->toArray();
обратите внимание на withTVs в методе GetRootTree необходимо передавать с доп параметрами
$docs = SiteContent::descendantsOf(2)
->withTVs(['tv1','tv2'])
->get()
->toTree()
->toArray();
$docs = SiteContent::descendantsOf(2)
->where('depth', '<', 4)
->get()
->toTree()
->toArray();
$docs = SiteContent::find(2)
->getChildren()
->pluck('id')
->toArray();
$docs = SiteContent::find(7)
->ancestors()
->orderBy('depth', 'desc')
->get();
ancestors()
ancestorsOf($id)
ancestorsWithSelf()
ancestorsWithSelfOf($id)
descendants()
descendantsOf($id)
descendantsWithSelf()
descendantsWithSelfOf($id)
childNode()
childNodeOf($id)
childAt(int $position)
childOf($id, int $position)
firstChild()
firstChildOf($id)
lastChild()
lastChildOf($id)
childrenRange(int $from, int $to = null)
childrenRangeOf($id, int $from, int $to = null)
sibling()
siblingOf($id)
siblings()
siblingsOf($id)
neighbors()
neighborsOf($id)
siblingAt(int $position)
siblingOfAt($id, int $position)
firstSibling()
firstSiblingOf($id)
lastSibling()
lastSiblingOf($id)
prevSibling()
prevSiblingOf($id)
prevSiblings()
prevSiblingsOf($id)
nextSibling()
nextSiblingOf($id)
nextSiblings()
nextSiblingsOf($id)
siblingsRange(int $from, int $to = null)
siblingsRangeOf($id, int $from, int $to = null)
Более детально так же можно ознакомиться тут : https://github.com/franzose/ClosureTable/blob/master/README.md
В целом работая с компонентами Laravel мы получаем больше свободы и более понятный код. К примеру если использовать все описанное выше то нет необходимости в Сниппете DocLister, собстввнно пооэтому он и был удален из набора по умолчанию в Evo 3.
Вопрос небольшой появился про TV-поля.
А как выбрать TV-поля типа связи?
В примере показано как выбирать и фильтровать обычные поля типа text, varchar, int....