Commit 7f604d04 authored by Nicolas Widart's avatar Nicolas Widart

Add method to get menu items for public routing

parent 6416eb4b
<?php namespace Modules\Menu\Repositories\Eloquent;
use Illuminate\Support\Facades\DB;
use Modules\Core\Internationalisation\Helper;
use Modules\Core\Repositories\Eloquent\EloquentBaseRepository;
use Modules\Menu\Entities\Menuitem;
......@@ -38,4 +39,28 @@ class EloquentMenuItemRepository extends EloquentBaseRepository implements MenuI
{
return $this->model->roots()->orderBy('position')->get();
}
/**
* Get Items to build routes
*
* @return Array
*/
public function getForRoutes()
{
$menuitems = DB::table('menuitems')
->select('menuitems.id', 'menuitems.parent_id', 'uri', 'locale', 'module_name')
->join('menuitem_translations', 'menuitems.id', '=', 'menuitem_translations.menuitem_id')
->where('uri', '!=', '')
->where('module_name', '!=', '')
->where('status', '=', 1)
->orderBy('module_name')
->get();
$menuitemsArray = [];
foreach ($menuitems as $menuitem) {
$menuitemsArray[$menuitem->module_name][$menuitem->locale] = $menuitem->locale . '/' .$menuitem->uri;
}
return $menuitemsArray;
}
}
......@@ -4,5 +4,15 @@ use Modules\Core\Repositories\BaseRepository;
interface MenuItemRepository extends BaseRepository
{
/**
* Get all root elements
* @return mixed
*/
public function roots();
/**
* Get the menu items ready for routes
* @return mixed
*/
public function getForRoutes();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment