diff --git a/app/Http/Controllers/Settings/PageController.php b/app/Http/Controllers/Settings/PageController.php index bf67cb9..da7c267 100644 --- a/app/Http/Controllers/Settings/PageController.php +++ b/app/Http/Controllers/Settings/PageController.php @@ -81,20 +81,34 @@ class PageController extends Controller /** * Update the specified resource in storage. * - * @param @param \App\Http\Requests\Pages\UpdatePageRequest $request - * @param \App\Models\Page $page + * @param \App\Http\Requests\Pages\UpdatePageRequest $request + * @param int $id * @return \Illuminate\Http\Response */ - public function update(UpdatePageRequest $request, Page $page) : RedirectResponse + public function update(UpdatePageRequest $request, $id) { + $page = Page::findOrFail($id); // $this->pages->update($page, $request->except(['_method', '_token'])); - $input = $request->except(['_method', '_token']); + $input = $request + ->except(['_method', '_token', 'nav-tab', 'en_title', 'en_description', 'de_title', 'de_description']); // Making extra fields //$input['page_slug'] = str_slug($input['title']); $input['status'] = isset($input['status']) ? 1 : 0; $input['updated_by'] = \Auth::user()->id; - if ($page->update($input)) { + $article_data = [ + 'en' => [ + 'title' => $request->input('en_title'), + 'description' => $request->input('en_description') + ], + 'de' => [ + 'title' => $request->input('de_title'), + 'description' => $request->input('de_description') + ], + ]; + $ergebnis = array_merge($input, $article_data); + + if ($page->update($ergebnis)) { event(new PageUpdated($page)); return redirect() diff --git a/app/Http/Requests/Pages/UpdatePageRequest.php b/app/Http/Requests/Pages/UpdatePageRequest.php index 9060983..81e5e58 100644 --- a/app/Http/Requests/Pages/UpdatePageRequest.php +++ b/app/Http/Requests/Pages/UpdatePageRequest.php @@ -16,7 +16,8 @@ class UpdatePageRequest extends Request */ public function authorize() { - return true;//return access()->allow('edit-page'); + return true; + //return access()->allow('edit-page'); } /** @@ -27,8 +28,8 @@ class UpdatePageRequest extends Request public function rules() { return [ - 'title' => 'required|max:191', - 'description' => 'required', + 'en_title' => 'required|max:191' + // 'description_en' => 'required' ]; } } diff --git a/app/Http/Requests/Person/EditPersonRequest.php b/app/Http/Requests/Person/EditPersonRequest.php index 21ce4b9..271681c 100644 --- a/app/Http/Requests/Person/EditPersonRequest.php +++ b/app/Http/Requests/Person/EditPersonRequest.php @@ -6,7 +6,7 @@ use Illuminate\Validation\Rule; //https://packagist.org/packages/felixkiss/uniquewith-validator -class CreatePersonRequest extends Request +class EditPersonRequest extends Request { /** * Determine if the user is authorized to make this request. diff --git a/app/Models/Page.php b/app/Models/Page.php index 9ed2493..368be24 100644 --- a/app/Models/Page.php +++ b/app/Models/Page.php @@ -2,6 +2,7 @@ namespace App\Models; +// 1. To specify package’s class you are using use App\Models\ModelTrait; use App\Models\User; use Illuminate\Database\Eloquent\Model; @@ -10,16 +11,18 @@ use Dimsav\Translatable\Translatable; class Page extends Model { use ModelTrait; - use Translatable; - /** + use Translatable; // 2. To add translation methods + + // 3. To define which attributes needs to be translated + public $translatedAttributes = ['title', 'description']; + + /** * The database table used by the model. * * @var string */ protected $table; - - public $translatedAttributes = ['title', 'description']; - + /** * The guarded field which are not mass assignable. * diff --git a/app/Models/PageTranslation.php b/app/Models/PageTranslation.php index b5e6316..f17f16a 100644 --- a/app/Models/PageTranslation.php +++ b/app/Models/PageTranslation.php @@ -8,6 +8,6 @@ use Illuminate\Database\Eloquent\Model; class PageTranslation extends Model { public $timestamps = false; - //protected $fillable = ['description']; + protected $fillable = ['title', 'description']; protected $guarded = ['id']; } diff --git a/public/backend/tabs.css b/public/backend/tabs.css new file mode 100644 index 0000000..c2b499f --- /dev/null +++ b/public/backend/tabs.css @@ -0,0 +1,169 @@ +.tabs { + -webkit-overflow-scrolling: touch; + align-items: stretch; + display: flex; + font-size: 1rem; + justify-content: space-between; + overflow: hidden; + overflow-x: auto; + white-space: nowrap; + } + + .tabs a { + align-items: center; + border-bottom-color: #dbdbdb; + border-bottom-style: solid; + border-bottom-width: 1px; + color: #4a4a4a; + display: flex; + justify-content: center; + margin-bottom: -1px; + padding: 0.5em 1em; + vertical-align: top; + } + + .tabs a:hover { + border-bottom-color: #363636; + color: #363636; + } + + .tabs li { + display: block; + } + + .tabs li.is-active a { + border-bottom-color: #3273dc; + color: #3273dc; + } + + .tabs ul { + align-items: center; + border-bottom-color: #dbdbdb; + border-bottom-style: solid; + border-bottom-width: 1px; + display: flex; + flex-grow: 1; + flex-shrink: 0; + justify-content: flex-start; + } + + .tabs ul.is-left { + padding-right: 0.75em; + } + + .tabs ul.is-center { + flex: none; + justify-content: center; + padding-left: 0.75em; + padding-right: 0.75em; + } + + .tabs ul.is-right { + justify-content: flex-end; + padding-left: 0.75em; + } + + .tabs .icon:first-child { + margin-right: 0.5em; + } + + .tabs .icon:last-child { + margin-left: 0.5em; + } + + .tabs.is-centered ul { + justify-content: center; + } + + .tabs.is-right ul { + justify-content: flex-end; + } + + .tabs.is-boxed a { + border: 1px solid transparent; + border-radius: 4px 4px 0 0; + } + + .tabs.is-boxed a:hover { + background-color: whitesmoke; + border-bottom-color: #dbdbdb; + } + + .tabs.is-boxed li.is-active a { + background-color: white; + border-color: #dbdbdb; + border-bottom-color: transparent !important; + } + + .tabs.is-fullwidth li { + flex-grow: 1; + flex-shrink: 0; + } + + .tabs.is-toggle a { + border-color: #dbdbdb; + border-style: solid; + border-width: 1px; + margin-bottom: 0; + position: relative; + } + + .tabs.is-toggle a:hover { + background-color: whitesmoke; + border-color: #b5b5b5; + z-index: 2; + } + + .tabs.is-toggle li + li { + margin-left: -1px; + } + + .tabs.is-toggle li:first-child a { + border-radius: 4px 0 0 4px; + } + + .tabs.is-toggle li:last-child a { + border-radius: 0 4px 4px 0; + } + + .tabs.is-toggle li.is-active a { + background-color: #3273dc; + border-color: #3273dc; + color: #fff; + z-index: 1; + } + + .tabs.is-toggle ul { + border-bottom: none; + } + + .tabs.is-toggle.is-toggle-rounded li:first-child a { + border-bottom-left-radius: 290486px; + border-top-left-radius: 290486px; + padding-left: 1.25em; + } + + .tabs.is-toggle.is-toggle-rounded li:last-child a { + border-bottom-right-radius: 290486px; + border-top-right-radius: 290486px; + padding-right: 1.25em; + } + + .tabs.is-small { + font-size: 0.75rem; + } + + .tabs.is-medium { + font-size: 1.25rem; + } + + .tabs.is-large { + font-size: 1.5rem; + } + + .tab-pane { + /* background-color: azure; */ + /* border: 1px solid #dbdbdb; */ + border-bottom: 1px solid #dbdbdb; + padding: 1rem 1rem 1rem 1rem; + } \ No newline at end of file diff --git a/resources/views/settings/layouts/app.blade.php b/resources/views/settings/layouts/app.blade.php index d275311..295c69b 100644 --- a/resources/views/settings/layouts/app.blade.php +++ b/resources/views/settings/layouts/app.blade.php @@ -15,6 +15,7 @@ + @yield('styles') diff --git a/resources/views/settings/page/edit.blade.php b/resources/views/settings/page/edit.blade.php index a926f84..7221db1 100644 --- a/resources/views/settings/page/edit.blade.php +++ b/resources/views/settings/page/edit.blade.php @@ -8,15 +8,16 @@ @endsection --}} -@section('content') {{ Form::model($page, ['method' => 'PATCH', 'route' => ['settings.page.update', $page], -'class' => 'pure-form pure-form-aligned', 'id' => 'edit-role', 'enctype' => 'multipart/form-data']) }} +@section('content') +{!! Form::model($page, ['method' => 'PATCH', 'route' => ['settings.page.update', $page->id], +'class' => 'pure-form pure-form-aligned', 'enctype' => 'multipart/form-data']) !!}

{{ trans('labels.backend.pages.edit') }}

-
+
{{-- @include('backend.pages.partials.pages-header-buttons') --}}
@@ -24,119 +25,127 @@
-
- {{ Form::label('title', trans('validation.attributes.backend.pages.title'), ['class' => 'col-lg-2 control-label required']) - }} -
- {{ Form::text('title', null, ['class' => 'form-control box-size', 'placeholder' => trans('validation.attributes.backend.pages.title'), - 'required' => 'required', 'readonly' => 'true']) }} -
- -
- + + + + +
+
    + + +
+
-
- {{ Form::label('description', trans('validation.attributes.backend.pages.description'), ['class' => 'col-lg-2 control-label - required']) }} -
- {{ Form::textarea('description', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.pages.description')]) - }} -
- -
- + +
- {{-- -
- {{ Form::label('language', 'Language..', ['class' => 'col-lg-2 control-label required']) }} -
- {{ Form::select('language', $languages, $page->language, ['placeholder' => '--no language--']) }} -
-
--}} - -
- {{ Form::label('cannonical_link', trans('validation.attributes.backend.pages.cannonical_link'), ['class' => 'col-lg-2 control-label']) - }} -
- {{ Form::text('cannonical_link', null, ['class' => 'form-control box-size', 'placeholder' => trans('validation.attributes.backend.pages.cannonical_link')]) - }} -
- -
- - -
- {{ Form::label('seo_title', trans('validation.attributes.backend.pages.seo_title'), ['class' => 'col-lg-2 control-label']) - }} -
- {{ Form::text('seo_title', null, ['class' => 'form-control box-size', 'placeholder' => trans('validation.attributes.backend.pages.seo_title')]) - }} -
- -
- - -
- {{ Form::label('seo_keyword', trans('validation.attributes.backend.pages.seo_keyword'), ['class' => 'col-lg-2 control-label']) - }} -
- {{ Form::text('seo_keyword', null, ['class' => 'form-control box-size', 'placeholder' => trans('validation.attributes.backend.pages.seo_keyword')]) - }} -
- -
- - -
- {{ Form::label('seo_description', trans('validation.attributes.backend.pages.seo_description'), ['class' => 'col-lg-2 control-label']) - }} -
- {{ Form::textarea('seo_description', null,['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.pages.seo_description')]) - }} -
- -
- - -
- {{ Form::label('status', trans('validation.attributes.backend.pages.is_active'), ['class' => 'col-lg-2 control-label']) }} - -
-
- +
+
+ {!! Form::label('en_title', trans('validation.attributes.backend.pages.title'), ['class' => 'col-lg-2 control-label required']) + !!} +
+ {!! Form::text('en_title', $page->translate('en')->title, ['class' => 'form-control box-size', 'placeholder' => trans('validation.attributes.backend.pages.title'), + 'required' => 'required', 'readonly' => 'true']) !!} +
+
+ +
+ {!! Form::label('en_description', trans('validation.attributes.backend.pages.description'), ['class' => 'col-lg-2 control-label + required']) !!} +
+ {!! Form::textarea('en_description', $page->translate('en')->description, ['class' => 'form-control description', 'placeholder' => trans('validation.attributes.backend.pages.description')]) + !!} +
+
+
+ +
+
+ {!! Form::label('de_title', trans('validation.attributes.backend.pages.title'), ['class' => 'col-lg-2 control-label required']) + !!} +
+ {!! Form::text('de_title', $page->translate('de')->title, ['class' => 'form-control box-size', 'placeholder' => trans('validation.attributes.backend.pages.title'), + 'required' => 'required', 'readonly' => 'true']) !!} +
+
+
+ {!! Form::label('de_description', trans('validation.attributes.backend.pages.description'), ['class' => 'col-lg-2 control-label + required']) !!} +
+ {!! Form::textarea('de_description', $page->translate('de')->description, ['class' => 'form-control description', 'placeholder' => trans('validation.attributes.backend.pages.description')]) + !!} +
-
- + +
+ {!! Form::label('status', trans('validation.attributes.backend.pages.is_active'), ['class' => 'col-lg-2 control-label']) !!} +
+ +
+
- {{ link_to_route('settings.page.index', trans('buttons.general.cancel'), [], ['class' => 'pure-button button-small is-warning']) - }} {{ Form::submit(trans('buttons.general.crud.update'), ['class' => 'pure-button button-small is-primary']) - }} -
+ {{ link_to_route('settings.page.index', trans('buttons.general.cancel'), [], ['class' => 'pure-button button-small is-warning']) }} + {!! Form::submit(trans('buttons.general.crud.update'), ['class' => 'pure-button button-small is-primary']) !!}
- +
- -{{ Form::close() }} + + +@include('errors._errors') +{!! Form::close() !!} @endsection +@section('styles') +{{-- --}} + + +@endsection + @section("after-scripts") @endsection \ No newline at end of file diff --git a/resources/views/settings/person/person.blade.php b/resources/views/settings/person/person.blade.php index 904b7d1..c89eb3f 100644 --- a/resources/views/settings/person/person.blade.php +++ b/resources/views/settings/person/person.blade.php @@ -53,7 +53,9 @@ {{ $person->documents->count() }}   -   + @if($person->documents->count() == 0) +   + @endif @endforeach diff --git a/routes/web.php b/routes/web.php index 34a2ba8..0b0b72d 100644 --- a/routes/web.php +++ b/routes/web.php @@ -90,15 +90,28 @@ Route::group( /* * CMS Pages Management============================================================================= */ -Route::group(['namespace' => 'Settings', 'prefix' => 'settings', 'as' => 'settings.',], function () { - Route::resource('page', 'PageController', ['except' => ['show', 'update']]); - - Route::patch('page/{page}', [ - 'as' => 'page.update', 'uses' => 'PageController@update', - ]); - // //For DataTables - Route::get('pages/get', ['uses' => 'PagesTableController@get'])->name('page.get'); -}); +Route::group( + [ + 'middleware' => ['permission:settings'], + 'namespace' => 'Settings', + 'prefix' => 'settings', + 'as' => 'settings.' + ], + function () { + //Route::resource('page', 'PageController', ['except' => ['show', 'update']]); + Route::get('user', [ + 'as' => 'page.index', 'uses' => 'PageController@index', + ]); + Route::get('page/edit/{page}', [ + 'as' => 'page.edit', 'uses' => 'PageController@edit', + ]); + Route::patch('page/update/{id}', [ + 'as' => 'page.update', 'uses' => 'PageController@update', + ]); + // //For DataTables + Route::get('pages/get', ['uses' => 'PagesTableController@get'])->name('page.get'); + } +); //=================================================setting home - dashboard=======================================