FEATURE: add translations and more friendly look to categories
This commit is contained in:
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
use App\Http\Requests\Request;
|
use App\Http\Requests\Request;
|
||||||
use App\Models\Module;
|
use App\Models\Module;
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Modules\Categories\Entities\Category;
|
use Modules\Categories\Entities\Category;
|
||||||
use Pingpong\Modules\Routing\Controller;
|
use Pingpong\Modules\Routing\Controller;
|
||||||
@@ -52,19 +51,27 @@ class EditCategory extends Controller
|
|||||||
|
|
||||||
$category->save();
|
$category->save();
|
||||||
|
|
||||||
|
if ($category->parent_id !== $request->parentCategory) {
|
||||||
if ($category->parent_id != $request->parentCategory) {
|
|
||||||
$category->parent_id = empty($request->parentCategory) ? null : $request->parentCategory;
|
$category->parent_id = empty($request->parentCategory) ? null : $request->parentCategory;
|
||||||
$category->save();
|
$category->save();
|
||||||
|
|
||||||
if (empty($request->parentCategory)) {
|
if (empty($request->parentCategory)) {
|
||||||
$category->makeRoot(1);
|
$category->makeRoot($category->position);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return redirect()
|
return redirect()
|
||||||
->route('categories.edit', ['id' => $id])
|
->route('categories.edit', ['id' => $id])
|
||||||
->with('success', trans('categories::categories.saveSuccessfull'));
|
->with('success', trans('categories::categories.saveSuccessfull'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function delete($id) {
|
||||||
|
$category = Category::findOrFail($id);
|
||||||
|
|
||||||
|
$category->delete();
|
||||||
|
|
||||||
|
return redirect()
|
||||||
|
->route('categories.overview')
|
||||||
|
->with('success', trans('categories::categories.deleteSuccessfull'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
return [
|
||||||
|
"actions" => "Akce",
|
||||||
|
"deleteSuccessfull" => "Kategorie úspěšně smazána",
|
||||||
|
"description" => "Modul pro správu a kategorizaci obsahu.",
|
||||||
|
"edit" => "Úprava kategorie",
|
||||||
|
"fields" => ["description" => "Popis",
|
||||||
|
"module" => "Modul",
|
||||||
|
"name" => "Jméno",
|
||||||
|
"parentCategory" => "Rodičovská kategorie",
|
||||||
|
"save" => "Uložit",
|
||||||
|
"url" => "URL",
|
||||||
|
],
|
||||||
|
"module" => "Modul",
|
||||||
|
"name" => "Kategorie",
|
||||||
|
"new" => "Nová kategorie",
|
||||||
|
"noCategories" => "Žádná vytvořená kategorie.",
|
||||||
|
"overview" => "Všechny kategorie",
|
||||||
|
"saveSuccessfull" => "Kategorie úspěšně uložena",
|
||||||
|
];
|
||||||
@@ -4,4 +4,18 @@ return [
|
|||||||
'description' => 'Module for category management and content categorization.',
|
'description' => 'Module for category management and content categorization.',
|
||||||
'new' => 'New category',
|
'new' => 'New category',
|
||||||
'overview' => 'All categories',
|
'overview' => 'All categories',
|
||||||
|
'fields' => [
|
||||||
|
'name' => 'Name',
|
||||||
|
'description' => 'Description',
|
||||||
|
'url' => 'URL',
|
||||||
|
'module' => 'Module',
|
||||||
|
'parentCategory' => 'Parent category',
|
||||||
|
'save' => 'Save category'
|
||||||
|
],
|
||||||
|
'edit' => 'Edit category',
|
||||||
|
'saveSuccessfull' => 'Category successfully saved',
|
||||||
|
'deleteSuccessfull' => 'Category successfully deleted',
|
||||||
|
'module' => 'Module',
|
||||||
|
'actions' => 'Actions',
|
||||||
|
'noCategories' => 'No categories available'
|
||||||
];
|
];
|
||||||
@@ -3,5 +3,17 @@
|
|||||||
@section('content')
|
@section('content')
|
||||||
<h2>@lang('categories::categories.edit')</h2>
|
<h2>@lang('categories::categories.edit')</h2>
|
||||||
|
|
||||||
|
@if (session('success'))
|
||||||
|
<div data-alert class="callout success">
|
||||||
|
<strong>{{ session('success') }}</strong>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@if (session('error'))
|
||||||
|
<div data-alert class="callout alert">
|
||||||
|
<strong>{{ session('error') }}</strong>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
@include('categories::admin.form', ['action' => route('categories.postEdit', ['id' => $category->id])])
|
@include('categories::admin.form', ['action' => route('categories.postEdit', ['id' => $category->id])])
|
||||||
@endsection
|
@endsection
|
||||||
@@ -1,36 +1,52 @@
|
|||||||
<form action="{{$action}}" method="post">
|
<form action="{{$action}}" method="post">
|
||||||
{!! csrf_field() !!}
|
{!! csrf_field() !!}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
<div class="column large-5">
|
||||||
<label>
|
<label>
|
||||||
@lang('categories::categories.fields.name')
|
@lang('categories::categories.fields.name')
|
||||||
|
|
||||||
<input type="text" name="name" value="{{old('name', $category->name)}}">
|
<input type="text" name="name" class="slug-source" value="{{old('name', $category->name)}}">
|
||||||
</label>
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="column large-5">
|
||||||
<label>
|
<label>
|
||||||
@lang('categories::categories.fields.url')
|
@lang('categories::categories.fields.url')
|
||||||
|
|
||||||
<input type="text" name="url" value="{{old('url', $category->url)}}">
|
<input type="text" name="url" class="slug-target" value="{{old('url', $category->url)}}">
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="column large-2 text-center">
|
||||||
|
<label>
|
||||||
|
@lang('admin/contents.lockUrl')<br />
|
||||||
|
|
||||||
|
<input type="checkbox" value="1" id="lockUrl"
|
||||||
|
@if(old('lockUrl') || ($category->id > 0 && \Illuminate\Support\Str::slug($category->name) != $category->url)) checked
|
||||||
|
@endif name="lockUrl" />
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<label>
|
<label>
|
||||||
@lang('categories::categories.fields.description')
|
@lang('categories::categories.fields.description')
|
||||||
|
|
||||||
<textarea name="description">{{old('description', $category->description)}}</textarea>
|
<textarea name="description">{{old('description', $category->description)}}</textarea>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
@if(!$category->id)
|
<div class="row">
|
||||||
|
<div class="column large-6">
|
||||||
<label>
|
<label>
|
||||||
@lang('categories::categories.fields.module')
|
@lang('categories::categories.fields.module')
|
||||||
<select name="moduleId">
|
<select name="moduleId" @if($category->id) disabled @endif>
|
||||||
@foreach($modules as $module)
|
@foreach($modules as $module)
|
||||||
<option @if($module->id == $category->module_id) selected
|
<option @if($module->id == $category->module_id) selected
|
||||||
@endif value="{{$module->id}}">{{trans($module->name)}}</option>
|
@endif value="{{$module->id}}">{{trans($module->name)}}</option>
|
||||||
@endforeach
|
@endforeach
|
||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
@endif
|
</div>
|
||||||
|
<div class="column large-6">
|
||||||
|
@if(count($categories))
|
||||||
<label>
|
<label>
|
||||||
@lang('categories::categories.fields.parentCategory')
|
@lang('categories::categories.fields.parentCategory')
|
||||||
<select name="parentCategory">
|
<select name="parentCategory">
|
||||||
@@ -40,6 +56,8 @@
|
|||||||
@endforeach
|
@endforeach
|
||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button type="submit" class="button primary">@lang('categories::categories.fields.save')</button>
|
<button type="submit" class="button primary">@lang('categories::categories.fields.save')</button>
|
||||||
|
|||||||
@@ -3,5 +3,17 @@
|
|||||||
@section('content')
|
@section('content')
|
||||||
<h2>@lang('categories::categories.new')</h2>
|
<h2>@lang('categories::categories.new')</h2>
|
||||||
|
|
||||||
|
@if (session('success'))
|
||||||
|
<div data-alert class="callout success">
|
||||||
|
<strong>{{ session('success') }}</strong>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@if (session('error'))
|
||||||
|
<div data-alert class="callout alert">
|
||||||
|
<strong>{{ session('error') }}</strong>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
@include('categories::admin.form', ['action' => route('categories.postNew')])
|
@include('categories::admin.form', ['action' => route('categories.postNew')])
|
||||||
@endsection
|
@endsection
|
||||||
@@ -3,6 +3,19 @@
|
|||||||
@section('content')
|
@section('content')
|
||||||
<h2>@lang('categories::categories.overview')</h2>
|
<h2>@lang('categories::categories.overview')</h2>
|
||||||
|
|
||||||
|
@if (session('success'))
|
||||||
|
<div data-alert class="callout success">
|
||||||
|
<strong>{{ session('success') }}</strong>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@if (session('error'))
|
||||||
|
<div data-alert class="callout alert">
|
||||||
|
<strong>{{ session('error') }}</strong>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@if(count($categories))
|
||||||
<table class="full-width">
|
<table class="full-width">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -17,4 +30,7 @@
|
|||||||
@endforeach
|
@endforeach
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
@else
|
||||||
|
<em>@lang('categories::categories.noCategories')</em>
|
||||||
|
@endif
|
||||||
@stop
|
@stop
|
||||||
Reference in New Issue
Block a user