Commit 2cd2223f authored by Nicolas Widart's avatar Nicolas Widart

Merge commit '2f0c4209'

* commit '2f0c4209':
  Squashed 'Modules/Menu/' changes from c345f10..cd29d47
parents bf1c9e4c 2f0c4209
...@@ -8,6 +8,7 @@ use Modules\Menu\Entities\Menuitem; ...@@ -8,6 +8,7 @@ use Modules\Menu\Entities\Menuitem;
use Modules\Menu\Http\Requests\CreateMenuItemRequest; use Modules\Menu\Http\Requests\CreateMenuItemRequest;
use Modules\Menu\Http\Requests\UpdateMenuItemRequest; use Modules\Menu\Http\Requests\UpdateMenuItemRequest;
use Modules\Menu\Repositories\MenuItemRepository; use Modules\Menu\Repositories\MenuItemRepository;
use Modules\Page\Repositories\PageRepository;
class MenuItemController class MenuItemController
{ {
...@@ -19,16 +20,23 @@ class MenuItemController ...@@ -19,16 +20,23 @@ class MenuItemController
* @var Redirector * @var Redirector
*/ */
private $redirector; private $redirector;
/**
* @var PageRepository
*/
private $page;
public function __construct(MenuItemRepository $menuItem, Redirector $redirector) public function __construct(MenuItemRepository $menuItem, Redirector $redirector, PageRepository $page)
{ {
$this->menuItem = $menuItem; $this->menuItem = $menuItem;
$this->redirector = $redirector; $this->redirector = $redirector;
$this->page = $page;
} }
public function create(Menu $menu) public function create(Menu $menu)
{ {
return view('menu::admin.menuitems.create', compact('menu')); $pages = $this->page->all();
return view('menu::admin.menuitems.create', compact('menu', 'pages'));
} }
public function store(Menu $menu, CreateMenuItemRequest $request) public function store(Menu $menu, CreateMenuItemRequest $request)
...@@ -41,7 +49,9 @@ class MenuItemController ...@@ -41,7 +49,9 @@ class MenuItemController
public function edit(Menu $menu, Menuitem $menuItem) public function edit(Menu $menu, Menuitem $menuItem)
{ {
return view('menu::admin.menuitems.edit', compact('menu', 'menuItem')); $pages = $this->page->all();
return view('menu::admin.menuitems.edit', compact('menu', 'menuItem', 'pages'));
} }
public function update(Menu $menu, Menuitem $menuItem, UpdateMenuItemRequest $request) public function update(Menu $menu, Menuitem $menuItem, UpdateMenuItemRequest $request)
......
...@@ -6,9 +6,10 @@ class UpdateMenuRequest extends FormRequest ...@@ -6,9 +6,10 @@ class UpdateMenuRequest extends FormRequest
{ {
public function rules() public function rules()
{ {
$menu = $this->route()->getParameter('menus');
return [ return [
'name' => 'required', 'name' => 'required',
'primary' => 'unique:menus', 'primary' => "unique:menus,primary,{$menu->id}",
]; ];
} }
......
...@@ -50,7 +50,7 @@ class EloquentMenuItemRepository extends EloquentBaseRepository implements MenuI ...@@ -50,7 +50,7 @@ class EloquentMenuItemRepository extends EloquentBaseRepository implements MenuI
$menuitemsArray = []; $menuitemsArray = [];
foreach ($menuitems as $menuitem) { foreach ($menuitems as $menuitem) {
$menuitemsArray[$menuitem->module_name][$menuitem->locale] = $menuitem->locale . '/' . $menuitem->uri; $menuitemsArray[$menuitem->module_name][$menuitem->locale] = $menuitem->uri;
} }
return $menuitemsArray; return $menuitemsArray;
......
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
<label for="page">{{ trans('menu::menu-items.form.page') }}</label> <label for="page">{{ trans('menu::menu-items.form.page') }}</label>
<select class="form-control" name="page_id" id="page"> <select class="form-control" name="page_id" id="page">
<option value=""></option> <option value=""></option>
<?php foreach($pages as $page): ?>
<option value="{{ $page->id }}">{{ $page->title }}</option>
<?php endforeach; ?>
</select> </select>
</div> </div>
......
...@@ -2,6 +2,11 @@ ...@@ -2,6 +2,11 @@
<label for="page">{{ trans('menu::menu-items.form.page') }}</label> <label for="page">{{ trans('menu::menu-items.form.page') }}</label>
<select class="form-control" name="page_id" id="page"> <select class="form-control" name="page_id" id="page">
<option value=""></option> <option value=""></option>
<?php foreach($pages as $page): ?>
<option value="{{ $page->id }}" {{ $menuItem->page_id == $page->id ? 'selected' : '' }}>
{{ $page->title }}
</option>
<?php endforeach; ?>
</select> </select>
</div> </div>
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
{!! Form::text('name', Input::old('name'), ['class' => 'form-control', 'placeholder' => trans('menu::menu.form.name')]) !!} {!! Form::text('name', Input::old('name'), ['class' => 'form-control', 'placeholder' => trans('menu::menu.form.name')]) !!}
{!! $errors->first('Name', '<span class="help-block">:message</span>') !!} {!! $errors->first('Name', '<span class="help-block">:message</span>') !!}
</div> </div>
<div class="checkbox"> <div class="checkbox {{ $errors->has('primary') ? ' has-error' : '' }}">
<label for="primary"> <label for="primary">
<input id="primary" <input id="primary"
name="primary" name="primary"
...@@ -11,5 +11,6 @@ ...@@ -11,5 +11,6 @@
class="flat-blue" class="flat-blue"
value="1" /> value="1" />
{{ trans('menu::menu.form.primary') }} {{ trans('menu::menu.form.primary') }}
{!! $errors->first('primary', '<span class="help-block">:message</span>') !!}
</label> </label>
</div> </div>
{
"name": "asgardcms/menu-module",
"type": "asgard-module",
"description": "Menu module for AsgardCMS. Handles all the menus.",
"keywords": [
"asgardcms",
"menu",
"tree",
"nested sets"
],
"license": "MIT",
"authors": [
{
"name": "Nicolas Widart",
"email": "info@asgardcms.com",
"role": "Developer"
}
],
"support": {
"email": "support@asgardcms.com",
"issues": "https://github.com/AsgardCms/Menu/issues",
"source": "https://github.com/AsgardCms/Menu"
},
"require": {
"php": ">=5.4",
"composer/installers": "~1.0"
},
"minimum-stability": "dev"
}
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
"keywords": [ "keywords": [
], ],
"active": 1, "active": 1,
"priority": 2,
"providers": [ "providers": [
"Modules\\Menu\\Providers\\RouteServiceProvider", "Modules\\Menu\\Providers\\RouteServiceProvider",
"Modules\\Menu\\Providers\\MenuServiceProvider" "Modules\\Menu\\Providers\\MenuServiceProvider"
......
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