id | titile | parent_id
public function includeChilds(Menu $menu)
{
$childs = $menu->childs;
return $this->collection($childs, new MenuTransformer());
}
//...
return $this->collection($childs, new MenuTransformer())->serializeWith(new ArraySerializer());
//..
protected $with = ['childs']; //чтобы при получении любого экземпляра, тянулись его дети
public function childs()
{
return $this->hasMany(Menu::class, 'parent_id');
}
public function includeChilds(Menu $term)
{
$childs = $menu->childs;
return $this->collection($childs, new MenuTransformer());
}
@foreach($sections as $section)
{{ $section->title }}
@foreach($section->records()->take(4)->get() as $record)
{{$record->title}}
@endforeach
@endforeach