Commit 3bb7d888 authored by Nicolas Widart's avatar Nicolas Widart

Refactor for cleaner repository and views

parent 345db88b
......@@ -10,27 +10,12 @@ class EloquentMenuItemRepository extends EloquentBaseRepository implements MenuI
{
public function create($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'];
$translatableData = Helper::separateLanguages($data);
Helper::updateTranslated($menuItem, $translatableData);
return $menuItem;
return $this->model->create($data);
}
public function update($menuItem, $data)
{
$menuItem->menu_id = $data['menu_id'];
$menuItem->page_id = $data['page_id'];
$menuItem->target = $data['target'];
$menuItem->module_name = $data['module'];
$translatableData = Helper::separateLanguages($data);
Helper::updateTranslated($menuItem, $translatableData);
$menuItem->update($data);
return $menuItem;
}
......
......@@ -9,23 +9,12 @@ class EloquentMenuRepository extends EloquentBaseRepository implements MenuRepos
{
public function create($data)
{
$menu = new Menu;
$menu->name = $data['name'];
$menu->primary = $data['primary'];
$translatableData = Helper::separateLanguages($data);
Helper::updateTranslated($menu, $translatableData);
return $menu;
return $this->model->create($data);
}
public function update($menu, $data)
{
$menu->name = $data['name'];
$menu->primary = $data['primary'];
$translatableData = Helper::separateLanguages($data);
Helper::updateTranslated($menu, $translatableData);
$menu->update($data);
return $menu;
}
......
<div class='form-group{{ $errors->has("title[{$lang}]") ? ' has-error' : '' }}'>
{!! Form::label("title[{$lang}]", trans('menu::menu.form.title')) !!}
{!! Form::text("title[{$lang}]", Input::old("title[{$lang}]"), ['class' => 'form-control', 'placeholder' => trans('menu::menu.form.title')]) !!}
{!! $errors->first("title[{$lang}]", '<span class="help-block">:message</span>') !!}
<div class='form-group{{ $errors->has("{$lang}[title]") ? ' has-error' : '' }}'>
{!! Form::label("{$lang}[title]", trans('menu::menu.form.title')) !!}
{!! Form::text("{$lang}[title]", Input::old("{$lang}[title]"), ['class' => 'form-control', 'placeholder' => trans('menu::menu.form.title')]) !!}
{!! $errors->first("{$lang}[title]", '<span class="help-block">:message</span>') !!}
</div>
<div class="form-group">
{!! Form::label("uri[{$lang}]", trans('menu::menu.form.uri')) !!}
<div class='input-group{{ $errors->has("uri[{$lang}]") ? ' has-error' : '' }}'>
{!! Form::label("{$lang}[uri]", trans('menu::menu.form.uri')) !!}
<div class='input-group{{ $errors->has("{$lang}[uri]") ? ' has-error' : '' }}'>
<span class="input-group-addon">/{{ $lang }}/</span>
{!! Form::text("uri[{$lang}]", Input::old("uri[{$lang}]"), ['class' => 'form-control', 'placeholder' => trans('menu::menu.form.uri')]) !!}
{!! $errors->first("uri[{$lang}]", '<span class="help-block">:message</span>') !!}
{!! Form::text("{$lang}[uri]", Input::old("{$lang}[uri]"), ['class' => 'form-control', 'placeholder' => trans('menu::menu.form.uri')]) !!}
{!! $errors->first("{$lang}[uri]", '<span class="help-block">:message</span>') !!}
</div>
</div>
<div class="checkbox">
<label for="status[{{$lang}}]">
<input id="status[{{$lang}}]"
name="status[{{$lang}}]"
<label for="{{$lang}}[status]">
<input id="{{$lang}}[status]"
name="{{$lang}}[status]"
type="checkbox"
class="flat-blue"
value="1" />
......
<div class='form-group{{ $errors->has("title[{$lang}]") ? ' has-error' : '' }}'>
{!! Form::label("title[{$lang}]", trans('menu::menu.form.title')) !!}
{!! Form::text("title[{$lang}]", Input::old("title[{$lang}]", $menuItem->translate($lang)->title), ['class' => 'form-control', 'placeholder' => trans('menu::menu.form.title')]) !!}
{!! $errors->first("title[{$lang}]", '<span class="help-block">:message</span>') !!}
<div class='form-group{{ $errors->has("{$lang}[title]") ? ' has-error' : '' }}'>
{!! Form::label("{$lang}[title]", trans('menu::menu.form.title')) !!}
{!! Form::text("{$lang}[title]", Input::old("{$lang}[title]", $menuItem->translate($lang)->title), ['class' => 'form-control', 'placeholder' => trans('menu::menu.form.title')]) !!}
{!! $errors->first("{$lang}[title]", '<span class="help-block">:message</span>') !!}
</div>
<div class="form-group">
{!! Form::label("uri[{$lang}]", trans('menu::menu.form.uri')) !!}
<div class='input-group{{ $errors->has("uri[{$lang}]") ? ' has-error' : '' }}'>
{!! Form::label("{$lang}[uri]", trans('menu::menu.form.uri')) !!}
<div class='input-group{{ $errors->has("{$lang}[uri]") ? ' has-error' : '' }}'>
<span class="input-group-addon">/{{ $lang }}/</span>
{!! Form::text("uri[{$lang}]", Input::old("uri[{$lang}]", $menuItem->translate($lang)->uri), ['class' => 'form-control', 'placeholder' => trans('menu::menu.form.uri')]) !!}
{!! $errors->first("uri[{$lang}]", '<span class="help-block">:message</span>') !!}
{!! Form::text("{$lang}[uri]", Input::old("{$lang}[uri]", $menuItem->translate($lang)->uri), ['class' => 'form-control', 'placeholder' => trans('menu::menu.form.uri')]) !!}
{!! $errors->first("{$lang}[uri]", '<span class="help-block">:message</span>') !!}
</div>
</div>
<div class="checkbox">
<label for="status[{{$lang}}]">
<input id="status[{{$lang}}]"
name="status[{{$lang}}]"
<label for="{{$lang}}[status]">
<input id="{{$lang}}[status]"
name="{{$lang}}[status]"
type="checkbox"
class="flat-blue"
{{ (bool)$menuItem->translate($lang)->status ? 'checked' : '' }}
......
......@@ -3,3 +3,13 @@
{!! Form::text('name', Input::old('name'), ['class' => 'form-control', 'placeholder' => trans('menu::menu.form.name')]) !!}
{!! $errors->first('Name', '<span class="help-block">:message</span>') !!}
</div>
<div class="checkbox">
<label for="primary">
<input id="primary"
name="primary"
type="checkbox"
class="flat-blue"
value="1" />
{{ trans('menu::menu.form.primary') }}
</label>
</div>
<div class='form-group{{ $errors->has("title[{$lang}]") ? ' has-error' : '' }}'>
{!! Form::label("title[{$lang}]", trans('menu::menu.form.title')) !!}
{!! Form::text("title[{$lang}]", Input::old("title[{$lang}]"), ['class' => 'form-control', 'placeholder' => trans('menu::menu.form.title')]) !!}
{!! $errors->first("title[{$lang}]", '<span class="help-block">:message</span>') !!}
<div class='form-group{{ $errors->has("{$lang}[title]") ? ' has-error' : '' }}'>
{!! Form::label("{$lang}[title]", trans('menu::menu.form.title')) !!}
{!! Form::text("{$lang}[title]", Input::old("{$lang}[title]"), ['class' => 'form-control', 'placeholder' => trans('menu::menu.form.title')]) !!}
{!! $errors->first("{$lang}[title]", '<span class="help-block">:message</span>') !!}
</div>
<div class="checkbox">
<label for="status[{{$lang}}]">
<input id="status[{{$lang}}]"
name="status[{{$lang}}]"
<label for="{{$lang}}[status]">
<input id="{{$lang}}[status]"
name="{{$lang}}[status]"
type="checkbox"
class="flat-blue"
......
<div class='form-group{{ $errors->has("title[{$lang}]") ? ' has-error' : '' }}'>
{!! Form::label("title[{$lang}]", trans('menu::menu.form.title')) !!}
{!! Form::text("title[{$lang}]", Input::old("title[{$lang}]", $menu->translate($lang)->title), ['class' => 'form-control', 'placeholder' => trans('menu::menu.form.title')]) !!}
{!! $errors->first("title[{$lang}]", '<span class="help-block">:message</span>') !!}
<div class='form-group{{ $errors->has("{$lang}[title]") ? ' has-error' : '' }}'>
{!! Form::label("{$lang}[title]", trans('menu::menu.form.title')) !!}
{!! Form::text("{$lang}[title]", Input::old("{$lang}[title]", $menu->translate($lang)->title), ['class' => 'form-control', 'placeholder' => trans('menu::menu.form.title')]) !!}
{!! $errors->first("{$lang}[title]", '<span class="help-block">:message</span>') !!}
</div>
<div class="checkbox">
<label for="status[{{$lang}}]">
<input id="status[{{$lang}}]"
name="status[{{$lang}}]"
<label for="{{$lang}}[status]">
<input id="{{$lang}}[status]"
name="{{$lang}}[status]"
type="checkbox"
class="flat-blue"
{{ ((bool)$menu->translate($lang)->status) ? 'checked' : '' }}
......
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