add element child list
This commit is contained in:
parent
aa746fe3f0
commit
7350d747f3
9 changed files with 186 additions and 10 deletions
|
|
@ -61,6 +61,25 @@ class EloquentElementRepository implements ElementRepository
|
|||
return $elements;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Element[]
|
||||
*/
|
||||
public function findByParentElement(Element $parentElement): array
|
||||
{
|
||||
$models = ElementModel::where(
|
||||
'parent_element_id',
|
||||
$parentElement->getId(),
|
||||
)
|
||||
->orderBy('id')
|
||||
->get();
|
||||
$elements = [];
|
||||
foreach ($models as $model) {
|
||||
$elements[] = $this->toDomain($model);
|
||||
}
|
||||
|
||||
return $elements;
|
||||
}
|
||||
|
||||
private function toDomain(ElementModel $model): Element
|
||||
{
|
||||
$set = $this->setRepo->find($model->set_id);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue