<?php

use Mtc\Shop\Category;
use Mtc\Core\PaginationTemplate;

$parent_categories = Category::query()
    ->selectRaw('categories.*')
    ->active()
    ->where('sub_id', 0)
    ->where('is_online_doctor', true)
    ->orderBy('name')
    ->get();

foreach ($parent_categories as $parent_category) {
    $parent_category->sub_categories = Category::query()
        ->selectRaw('categories.*')
        ->active()
        ->where('sub_id', $parent_category->id)
        ->where('is_online_doctor', true)
        ->orderBy('name')
        ->get();
}

$twig_variables['parent_categories'] = $parent_categories;
