Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Platform
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Platform
Commits
7f604d04
Commit
7f604d04
authored
Nov 18, 2014
by
Nicolas Widart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add method to get menu items for public routing
parent
6416eb4b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
0 deletions
+35
-0
EloquentMenuItemRepository.php
Repositories/Eloquent/EloquentMenuItemRepository.php
+25
-0
MenuItemRepository.php
Repositories/MenuItemRepository.php
+10
-0
No files found.
Repositories/Eloquent/EloquentMenuItemRepository.php
View file @
7f604d04
<?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
;
}
}
Repositories/MenuItemRepository.php
View file @
7f604d04
...
...
@@ -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
();
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment