D
D
Dmitry Demidenko2018-10-30 12:48:43
Laravel
Dmitry Demidenko, 2018-10-30 12:48:43

How to make 2 menu items in sleepingowl from one model?

Hello!
I have a Services model. The object of this model has a parent_id field, those with parent_id = 0 are parent categories.
I can somehow display nesting using the same model:
Services
- Categories (only parent_id = 0 will be displayed here)
- Services themselves (all with parent_id > 0)

use SleepingOwl\Admin\Navigation\Page;

return [
    [
        'title' => 'Пользователи',
        'icon'  => 'fa fa-users',
        'pages' => [
            (new Page(\App\Models\User::class))->setTitle('Физические лица')->setUrl('admin/users/individual')
        ]
    ],
    [
        'title' => 'Разделы',
        'icon'  => 'fa fa-tasks',
        'pages' => [
            (new Page(\App\Models\Mission::class))->setTitle('Задания'),
            (new Page(\App\Models\Vacancy::class))->setTitle('Вакансии'),
            (new Page(\App\Models\Resume::class))->setTitle('Резюме'),
            (new Page(\App\Models\Auto::class))->setTitle('Авто'),
        ]
    ],
    [
        'title' => 'Финансы',
        'icon'  => 'fa fa-credit-card',
        'pages' => [
            (new Page(\App\Models\Tariff::class))
                ->setIcon('fa fa-money')
                ->setPriority(0)
        ]
    ],
    [
        'title' => 'Справочники',
        'icon'  => 'fa fa-book',
        'pages' => [
            [
                'title' => 'Общие',
                'pages' => [
                    (new Page(\App\Models\TariffCategory::class))
                        ->setTitle('Категории тарифов'),
                    (new Page(\App\Models\PayType::class))
                        ->setTitle('Методы оплаты'),
                    (new Page(\App\Models\Colours::class))
                        ->setTitle('Цвета'),
                    (new Page(\App\Models\Service::class))
                        ->setTitle('Категории услуг'),
                    (new Page(\App\Models\CategoryForWork::class))
                        ->setTitle('Категории для работы')
                ]
            ],
            [
                'title' => 'Авто',
                'pages' => [
                    (new Page(\App\Models\AutoCategory::class))->setTitle('Категории'),
                    (new Page(\App\Models\CarBodyType::class))->setTitle('Типы кузовов'),
                    (new Page(\App\Models\CarBrand::class))->setTitle('Марки'),
                    (new Page(\App\Models\CarModel::class))->setTitle('Модели'),
                    [
                        'title' => 'Вид',
                        'pages' => [
                            (new Page(\App\Models\CarOutside::class))->setTitle('Снаружи'),
                            (new Page(\App\Models\CarOptics::class))->setTitle('Оптика'),
                            (new Page(\App\Models\CarSalon::class))->setTitle('Салон'),
                            (new Page(\App\Models\CarMedia::class))->setTitle('Медиа'),
                            (new Page(\App\Models\CarOption::class))->setTitle('Опции'),
                            (new Page(\App\Models\CarAdditionally::class))->setTitle('Дополнительно'),
                        ]
                    ]
                ]
            ]
        ]
    ],
    [
        'title' => 'Информ',
        'icon'  => 'fa fa-exclamation-circle',
        'url'   => route('admin.information'),
    ],
];

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question