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
9a2295da
Commit
9a2295da
authored
Nov 14, 2014
by
Nicolas Widart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create a menu item
parent
838c1ec7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
4 deletions
+25
-4
MenuItemController.php
Http/Controllers/Admin/MenuItemController.php
+22
-1
EloquentMenuItemRepository.php
Repositories/Eloquent/EloquentMenuItemRepository.php
+2
-2
create-fields.blade.php
...es/views/admin/menuitems/partials/create-fields.blade.php
+1
-1
No files found.
Http/Controllers/Admin/MenuItemController.php
View file @
9a2295da
<?php
namespace
Modules\Menu\Http\Controllers\Admin
;
use
Illuminate\Routing\Redirector
;
use
Laracasts\Flash\Flash
;
use
Modules\Menu\Entities\Menu
;
use
Modules\Menu\Http\Requests\CreateMenuItemRequest
;
use
Modules\Menu\Repositories\MenuItemRepository
;
class
MenuItemController
{
/**
* @var MenuItemRepository
*/
private
$menuItem
;
/**
* @var Redirector
*/
private
$redirector
;
public
function
__construct
(
MenuItemRepository
$menuItem
,
Redirector
$redirector
)
{
$this
->
menuItem
=
$menuItem
;
$this
->
redirector
=
$redirector
;
}
public
function
create
(
Menu
$menu
)
{
return
view
(
'menu::admin.menuitems.create'
,
compact
(
'menu'
));
...
...
@@ -12,7 +30,10 @@ class MenuItemController
public
function
store
(
Menu
$menu
,
CreateMenuItemRequest
$request
)
{
dd
(
'Form posted'
,
$menu
,
$request
->
all
());
$this
->
menuItem
->
create
(
array_merge
(
$request
->
all
(),
[
'menu_id'
=>
$menu
->
id
]));
Flash
::
success
(
'Menu item created!'
);
return
$this
->
redirector
->
route
(
'dashboard.menu.edit'
,
[
$menu
->
id
]);
}
public
function
update
(
Menu
$menu
)
...
...
Repositories/Eloquent/EloquentMenuItemRepository.php
View file @
9a2295da
<?php
namespace
Modules\Menu\Repositories\Eloquent
;
use
Modules\Core\Internationalisation\Helper
;
use
Modules\Core\Repositories\Eloquent\EloquentBaseRepository
;
use
Modules\Menu\Entities\Menuitem
;
use
Modules\Menu\Repositories\MenuItemRepository
;
...
...
@@ -8,12 +9,11 @@ class EloquentMenuItemRepository extends EloquentBaseRepository implements MenuI
{
public
function
create
(
$data
)
{
dd
(
$data
);
$menuItem
=
new
Menuitem
;
$menuItem
->
menu_id
=
$data
[
'menu_id'
];
$menuItem
->
page_id
=
$data
[
'page_id'
];
$menuItem
->
target
=
$data
[
'target'
];
$menuItem
->
module_name
=
$data
[
'module
_name
'
];
$menuItem
->
module_name
=
$data
[
'module'
];
unset
(
$data
[
'menu_id'
],
$data
[
'page_id'
],
$data
[
'target'
],
$data
[
'module_name'
]);
...
...
Resources/views/admin/menuitems/partials/create-fields.blade.php
View file @
9a2295da
<div
class=
"form-group"
>
<label
for=
"page"
>
{{ trans('menu::menu-items.form.page') }}
</label>
<select
class=
"form-control"
name=
"page"
id=
"page"
>
<select
class=
"form-control"
name=
"page
_id
"
id=
"page"
>
<option
value=
""
></option>
</select>
</div>
...
...
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