From b296ec58a50645a441fa9d93510a71a704fcc731 Mon Sep 17 00:00:00 2001 From: Aan Choesni Herlingga <aanchoesni@unesa.ac.id> Date: Fri, 13 Dec 2019 09:47:57 +0700 Subject: [PATCH] master setting --- app/Http/Controllers/Webprofile/Backend/SettingController.php | 123 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ app/Http/Requests/SettingRequest.php | 43 +++++++++++++++++++++++++++++++++++++++++++ resources/lang/en/label.php | 2 ++ resources/lang/id/label.php | 2 ++ resources/views/webprofile/backend/categories/create.blade.php | 2 +- resources/views/webprofile/backend/categories/edit.blade.php | 2 +- resources/views/webprofile/backend/categories/index.blade.php | 2 +- resources/views/webprofile/backend/informations/create.blade.php | 2 +- resources/views/webprofile/backend/informations/edit.blade.php | 2 +- resources/views/webprofile/backend/informations/index.blade.php | 2 +- resources/views/webprofile/backend/layouts/navigations/admin.blade.php | 2 +- resources/views/webprofile/backend/pages/create.blade.php | 2 +- resources/views/webprofile/backend/pages/edit.blade.php | 2 +- resources/views/webprofile/backend/pages/index.blade.php | 2 +- resources/views/webprofile/backend/posts/create.blade.php | 2 +- resources/views/webprofile/backend/posts/edit.blade.php | 2 +- resources/views/webprofile/backend/posts/index.blade.php | 2 +- resources/views/webprofile/backend/setting/create.blade.php | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ resources/views/webprofile/backend/setting/edit.blade.php | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ resources/views/webprofile/backend/setting/index.blade.php | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ routes/webprofile/backend.php | 1 + 21 files changed, 374 insertions(+), 13 deletions(-) create mode 100644 app/Http/Controllers/Webprofile/Backend/SettingController.php create mode 100644 app/Http/Requests/SettingRequest.php create mode 100644 resources/views/webprofile/backend/setting/create.blade.php create mode 100644 resources/views/webprofile/backend/setting/edit.blade.php create mode 100644 resources/views/webprofile/backend/setting/index.blade.php diff --git a/app/Http/Controllers/Webprofile/Backend/SettingController.php b/app/Http/Controllers/Webprofile/Backend/SettingController.php new file mode 100644 index 0000000..2391e1f --- /dev/null +++ b/app/Http/Controllers/Webprofile/Backend/SettingController.php @@ -0,0 +1,123 @@ +<?php + +namespace App\Http\Controllers\Webprofile\Backend; + +use App\Models\Webprofile\Setting; +use Illuminate\Http\Request; +use App\Http\Controllers\Controller; +use Validator; +use Uuid; +use Alert; +use Session; +use Crypt; +use App\Helpers\InseoHelper; +use App\Http\Requests\SettingRequest; +use Auth; + +class SettingController extends Controller +{ + /** + * Display a listing of the resource. + * + * @return \Illuminate\Http\Response + */ + public function index() + { + $data = Setting::orderBy('name_setting', 'ASC')->get(); + + $data = [ + 'data' => $data, + ]; + + return view('webprofile.backend.setting.index', $data)->withTitle(trans('feature.setting')); + } + + /** + * Show the form for creating a new resource. + * + * @return \Illuminate\Http\Response + */ + public function create() + { + return view('webprofile.backend.setting.create')->withTitle(trans('feature.create_setting')); + } + + /** + * Store a newly created resource in storage. + * + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Http\Response + */ + public function store(SettingRequest $request) + { + $data = $request->except('_token'); + + $data['userid_created'] = Auth::user()->id; + $data['userid_updated'] = Auth::user()->id; + + Setting::create($data); + + Alert::success('Data berhasil disimpan')->persistent('Ok'); + + $successmessage = "Proses Tambah Pengaturan Berhasil !!"; + return redirect()->route('settings.index')->with('successMessage', $successmessage); + } + + /** + * Display the specified resource. + * + * @param \App\Models\Setting $setting + * @return \Illuminate\Http\Response + */ + public function show(Setting $setting) + { + // + } + + /** + * Show the form for editing the specified resource. + * + * @param \App\Models\Setting $setting + * @return \Illuminate\Http\Response + */ + public function edit($id) + { + try { + $data = Setting::find(Crypt::decrypt($id)); + return view('webprofile.backend.setting.edit', compact('data'))->withTitle(trans('feature.edit_setting')); + } catch (\Exception $id) { + return redirect()->route('settings.index'); + } + } + + /** + * Update the specified resource in storage. + * + * @param \Illuminate\Http\Request $request + * @param \App\Models\Setting $setting + * @return \Illuminate\Http\Response + */ + public function update(SettingRequest $request, $id) + { + $setting = Setting::findOrFail($id); + + $data = $request->except('_token'); + + $data['userid_updated'] = Auth::user()->id; + $setting->update($data); + + Alert::success('Data berhasil diubah')->persistent('Ok'); + return redirect()->route('settings.index'); + } + + /** + * Remove the specified resource from storage. + * + * @param \App\Models\Setting $setting + * @return \Illuminate\Http\Response + */ + public function destroy($id) + { + // + } +} diff --git a/app/Http/Requests/SettingRequest.php b/app/Http/Requests/SettingRequest.php new file mode 100644 index 0000000..7221d41 --- /dev/null +++ b/app/Http/Requests/SettingRequest.php @@ -0,0 +1,43 @@ +<?php + +namespace App\Http\Requests; + +use Illuminate\Foundation\Http\FormRequest; + +class SettingRequest extends FormRequest +{ + /** + * Determine if the user is authorized to make this request. + * + * @return bool + */ + public function authorize() + { + return true; + } + + /** + * Get the validation rules that apply to the request. + * + * @return array + */ + public function rules() + { + return [ + 'name_setting' => 'required', + 'value_setting' => 'required', + ]; + } + + /** + * Get the validation rules that apply to the request. + * + * @return array + */ + public function messages() + { + return [ + 'required' => 'Form Input Ini Tidak Boleh Kosong / Harus Diisi', + ]; + } +} diff --git a/resources/lang/en/label.php b/resources/lang/en/label.php index dc6e25a..c3d2bdf 100644 --- a/resources/lang/en/label.php +++ b/resources/lang/en/label.php @@ -7,6 +7,7 @@ return [ 'update' => 'Update', 'delete' => 'Delete', 'save' => 'Save', + 'cancel' => 'Cancel', 'number' => 'Num', 'name' => 'Name', 'status' => 'Status', @@ -23,4 +24,5 @@ return [ 'viewer' => 'Viewer', 'command' => 'Command', 'event_date' => 'Event Date', + 'value' => 'Value', ]; diff --git a/resources/lang/id/label.php b/resources/lang/id/label.php index 3ebfee7..76790bc 100644 --- a/resources/lang/id/label.php +++ b/resources/lang/id/label.php @@ -7,6 +7,7 @@ return [ 'update' => 'Update', 'delete' => 'Hapus', 'save' => 'Simpan', + 'cancel' => 'Batal', 'number' => 'No', 'name' => 'Nama', 'status' => 'Status', @@ -23,4 +24,5 @@ return [ 'viewer' => 'Penonton', 'command' => 'Komentar', 'event_date' => 'Tanggal Kegiatan', + 'value' => 'Nilai', ]; \ No newline at end of file diff --git a/resources/views/webprofile/backend/categories/create.blade.php b/resources/views/webprofile/backend/categories/create.blade.php index d0a0acd..6217f6d 100644 --- a/resources/views/webprofile/backend/categories/create.blade.php +++ b/resources/views/webprofile/backend/categories/create.blade.php @@ -5,7 +5,7 @@ @stop @section('breadcrumbs') -<li><a href="{{URL::to('dashboard')}}">Dashboard</a></li> +<li><a href="{{ url('dashboard') }}">Dashboard</a></li> <li class="active">Tambah Kategori</li> @stop diff --git a/resources/views/webprofile/backend/categories/edit.blade.php b/resources/views/webprofile/backend/categories/edit.blade.php index fdecfab..993df27 100644 --- a/resources/views/webprofile/backend/categories/edit.blade.php +++ b/resources/views/webprofile/backend/categories/edit.blade.php @@ -5,7 +5,7 @@ @stop @section('breadcrumbs') -<li><a href="{{URL::to('dashboard')}}">Dashboard</a></li> +<li><a href="{{ url('dashboard') }}">Dashboard</a></li> <li class="active">Ubah Kategori</li> @stop diff --git a/resources/views/webprofile/backend/categories/index.blade.php b/resources/views/webprofile/backend/categories/index.blade.php index fc9db03..10339f9 100644 --- a/resources/views/webprofile/backend/categories/index.blade.php +++ b/resources/views/webprofile/backend/categories/index.blade.php @@ -10,7 +10,7 @@ @stop @section('breadcrumbs') -<li><a href="{{URL::to('dashboard')}}">@lang('label.dashboard')</a></li> +<li><a href="{{ url('dashboard') }}">@lang('label.dashboard')</a></li> <li class="active">@lang('feature.category')</li> @stop diff --git a/resources/views/webprofile/backend/informations/create.blade.php b/resources/views/webprofile/backend/informations/create.blade.php index db761da..478315d 100644 --- a/resources/views/webprofile/backend/informations/create.blade.php +++ b/resources/views/webprofile/backend/informations/create.blade.php @@ -14,7 +14,7 @@ @stop @section('breadcrumbs') -<li><a href="{{URL::to('dashboard')}}">@lang('label.dashboard')</a></li> +<li><a href="{{ url('dashboard') }}">@lang('label.dashboard')</a></li> <li class="active">@lang('feature.create_information')</li> @stop diff --git a/resources/views/webprofile/backend/informations/edit.blade.php b/resources/views/webprofile/backend/informations/edit.blade.php index 525905d..3301343 100644 --- a/resources/views/webprofile/backend/informations/edit.blade.php +++ b/resources/views/webprofile/backend/informations/edit.blade.php @@ -14,7 +14,7 @@ @stop @section('breadcrumbs') -<li><a href="{{URL::to('dashboard')}}">@lang('label.dashboard')</a></li> +<li><a href="{{ url('dashboard') }}">@lang('label.dashboard')</a></li> <li class="active">@lang('feature.create_information')</li> @stop diff --git a/resources/views/webprofile/backend/informations/index.blade.php b/resources/views/webprofile/backend/informations/index.blade.php index 9cb6df7..8919d24 100644 --- a/resources/views/webprofile/backend/informations/index.blade.php +++ b/resources/views/webprofile/backend/informations/index.blade.php @@ -10,7 +10,7 @@ @stop @section('breadcrumbs') -<li><a href="{{URL::to('dashboard')}}">@lang('label.dashboard')</a></li> +<li><a href="{{ url('dashboard') }}">@lang('label.dashboard')</a></li> <li class="active">@lang('feature.information')</li> @stop diff --git a/resources/views/webprofile/backend/layouts/navigations/admin.blade.php b/resources/views/webprofile/backend/layouts/navigations/admin.blade.php index e942fb7..8f80d2e 100644 --- a/resources/views/webprofile/backend/layouts/navigations/admin.blade.php +++ b/resources/views/webprofile/backend/layouts/navigations/admin.blade.php @@ -42,5 +42,5 @@ <a href="{{ url('webprofile/layouts') }}"><span class="fa fa-tasks"></span> <span class="xn-text">@lang('feature.layout')</span></a> </li> <li> - <a href="{{ url('webprofile/setting') }}"><span class="fa fa-gears"></span><span class="xn-text">@lang('feature.setting')</span></a> + <a href="{{ url('webprofile/settings') }}"><span class="fa fa-gears"></span><span class="xn-text">@lang('feature.setting')</span></a> </li> diff --git a/resources/views/webprofile/backend/pages/create.blade.php b/resources/views/webprofile/backend/pages/create.blade.php index 273a6cc..c86264b 100644 --- a/resources/views/webprofile/backend/pages/create.blade.php +++ b/resources/views/webprofile/backend/pages/create.blade.php @@ -14,7 +14,7 @@ @stop @section('breadcrumbs') -<li><a href="{{URL::to('dashboard')}}">@lang('label.dashboard')</a></li> +<li><a href="{{ url('dashboard') }}">@lang('label.dashboard')</a></li> <li class="active">@lang('feature.create_page')</li> @stop diff --git a/resources/views/webprofile/backend/pages/edit.blade.php b/resources/views/webprofile/backend/pages/edit.blade.php index 386ee8e..48c6a50 100644 --- a/resources/views/webprofile/backend/pages/edit.blade.php +++ b/resources/views/webprofile/backend/pages/edit.blade.php @@ -14,7 +14,7 @@ @stop @section('breadcrumbs') -<li><a href="{{URL::to('dashboard')}}">@lang('label.dashboard')</a></li> +<li><a href="{{ url('dashboard') }}">@lang('label.dashboard')</a></li> <li class="active">@lang('feature.create_page')</li> @stop diff --git a/resources/views/webprofile/backend/pages/index.blade.php b/resources/views/webprofile/backend/pages/index.blade.php index 51ed49d..c10f5c6 100644 --- a/resources/views/webprofile/backend/pages/index.blade.php +++ b/resources/views/webprofile/backend/pages/index.blade.php @@ -10,7 +10,7 @@ @stop @section('breadcrumbs') -<li><a href="{{URL::to('dashboard')}}">@lang('label.dashboard')</a></li> +<li><a href="{{ url('dashboard') }}">@lang('label.dashboard')</a></li> <li class="active">@lang('feature.page')</li> @stop diff --git a/resources/views/webprofile/backend/posts/create.blade.php b/resources/views/webprofile/backend/posts/create.blade.php index 0ece2c2..ae3c620 100644 --- a/resources/views/webprofile/backend/posts/create.blade.php +++ b/resources/views/webprofile/backend/posts/create.blade.php @@ -14,7 +14,7 @@ @stop @section('breadcrumbs') -<li><a href="{{URL::to('dashboard')}}">@lang('label.dashboard')</a></li> +<li><a href="{{ url('dashboard') }}">@lang('label.dashboard')</a></li> <li class="active">@lang('feature.create_post')</li> @stop diff --git a/resources/views/webprofile/backend/posts/edit.blade.php b/resources/views/webprofile/backend/posts/edit.blade.php index 8863618..d5eec8f 100644 --- a/resources/views/webprofile/backend/posts/edit.blade.php +++ b/resources/views/webprofile/backend/posts/edit.blade.php @@ -14,7 +14,7 @@ @stop @section('breadcrumbs') -<li><a href="{{URL::to('dashboard')}}">@lang('label.dashboard')</a></li> +<li><a href="{{ url('dashboard') }}">@lang('label.dashboard')</a></li> <li class="active">@lang('feature.create_post')</li> @stop diff --git a/resources/views/webprofile/backend/posts/index.blade.php b/resources/views/webprofile/backend/posts/index.blade.php index 3fd6240..f04ccbd 100644 --- a/resources/views/webprofile/backend/posts/index.blade.php +++ b/resources/views/webprofile/backend/posts/index.blade.php @@ -10,7 +10,7 @@ @stop @section('breadcrumbs') -<li><a href="{{URL::to('dashboard')}}">@lang('label.dashboard')</a></li> +<li><a href="{{ url('dashboard') }}">@lang('label.dashboard')</a></li> <li class="active">@lang('feature.post')</li> @stop diff --git a/resources/views/webprofile/backend/setting/create.blade.php b/resources/views/webprofile/backend/setting/create.blade.php new file mode 100644 index 0000000..e51a1f4 --- /dev/null +++ b/resources/views/webprofile/backend/setting/create.blade.php @@ -0,0 +1,65 @@ +@extends('webprofile.backend.layouts.master') + +@section('title') + {{ $title }} +@stop + +@section('breadcrumbs') +<li><a href="{{ url('dashboard') }}">@lang('label.dashboard')</a></li> +<li class="active">@lang('feature.create_setting')</li> +@stop + +@section('content') +{!! Form::open(array('url' => route('settings.store'), 'method' => 'POST', 'id' => 'setting', 'class' => 'form-horizontal')) !!} +{!! csrf_field() !!} +<!-- page start--> +<div class="row"> + <div class="col-md-12"> + <div class="panel panel-default"> + <div class="panel-heading"> + <h3 class="panel-title"><strong>@lang('label.create')</strong> @lang('feature.setting')</h3> + </div> + <div class="panel-body"> + <div class="row"> + <div class="col-md-12"> + <div class="form-group @if ($errors->has('name_setting')) has-error @endif"> + <label class="col-md-2 control-label">@lang('label.name') @lang('feature.setting')</label> + <div class="col-md-10"> + {{ Form::text('name_setting', old('name_setting'), array('class' => 'form-control')) }} + @if ($errors->has('name_setting')) + <label id="login-error" class="error" for="login">{{$errors->first('name_setting')}}</label> + @endif + </div> + </div> + <div class="form-group @if ($errors->has('value_setting')) has-error @endif"> + <label class="col-md-2 control-label">@lang('label.value') @lang('feature.setting')</label> + <div class="col-md-10"> + {{ Form::text('value_setting', old('value_setting'), array('class' => 'form-control')) }} + @if ($errors->has('value_setting')) + <label id="login-error" class="error" for="login">{{$errors->first('value_setting')}}</label> + @endif + </div> + </div> + </div> + </div> + </div> + </div> + </div> + <div class="col-md-12"> + <div class="panel panel-default"> + <div class="panel-footer"> + <a href="{{ url('settings') }}" class="btn btn-default pull-right">@lang('label.cancel')</a> + <button class="btn btn-info pull-right">@lang('label.save')</button> + </div> + </div> + </div> +</div> +{!! Form::close() !!} +<!-- page end--> +@stop + +@section('script') +{!! Html::script('backend/js/plugins/bootstrap/bootstrap-datepicker.js') !!} +{!! Html::script('backend/js/plugins/bootstrap/bootstrap-timepicker.min.js') !!} +{!! Html::script('backend/js/plugins/bootstrap/bootstrap-file-input.js') !!} +@stop diff --git a/resources/views/webprofile/backend/setting/edit.blade.php b/resources/views/webprofile/backend/setting/edit.blade.php new file mode 100644 index 0000000..f45ca58 --- /dev/null +++ b/resources/views/webprofile/backend/setting/edit.blade.php @@ -0,0 +1,65 @@ +@extends('webprofile.backend.layouts.master') + +@section('title') + {{ $title }} +@stop + +@section('breadcrumbs') +<li><a href="{{ url('dashboard') }}">@lang('label.dashboard')</a></li> +<li class="active">@lang('feature.edit_setting')</li> +@stop + +@section('content') +{!! Form::model($data, ['route' => ['settings.update', $data->id], 'method'=>'patch', 'class'=>'form-horizontal']) !!} +{!! csrf_field() !!} +<!-- page start--> +<div class="row"> + <div class="col-md-12"> + <div class="panel panel-default"> + <div class="panel-heading"> + <h3 class="panel-title"><strong>@lang('label.edit')</strong> @lang('feature.setting')</h3> + </div> + <div class="panel-body"> + <div class="row"> + <div class="col-md-12"> + <div class="form-group @if ($errors->has('name_setting')) has-error @endif"> + <label class="col-md-2 control-label">@lang('label.name') @lang('feature.setting')</label> + <div class="col-md-10"> + {{ Form::text('name_setting', old('name_setting'), array('class' => 'form-control', 'readonly', 'style' => 'color: black')) }} + @if ($errors->has('name_setting')) + <label id="login-error" class="error" for="login">{{$errors->first('name_setting')}}</label> + @endif + </div> + </div> + <div class="form-group @if ($errors->has('value_setting')) has-error @endif"> + <label class="col-md-2 control-label">@lang('label.value') @lang('feature.setting')</label> + <div class="col-md-10"> + {{ Form::text('value_setting', old('value_setting'), array('class' => 'form-control')) }} + @if ($errors->has('value_setting')) + <label id="login-error" class="error" for="login">{{$errors->first('value_setting')}}</label> + @endif + </div> + </div> + </div> + </div> + </div> + </div> + </div> + <div class="col-md-12"> + <div class="panel panel-default"> + <div class="panel-footer"> + <a href="{{ url('settings') }}" class="btn btn-default pull-right">@lang('label.cancel')</a> + <button class="btn btn-info pull-right">@lang('label.save')</button> + </div> + </div> + </div> +</div> +{!! Form::close() !!} +<!-- page end--> +@stop + +@section('script') +{!! Html::script('backend/js/plugins/bootstrap/bootstrap-datepicker.js') !!} +{!! Html::script('backend/js/plugins/bootstrap/bootstrap-timepicker.min.js') !!} +{!! Html::script('backend/js/plugins/bootstrap/bootstrap-file-input.js') !!} +@stop diff --git a/resources/views/webprofile/backend/setting/index.blade.php b/resources/views/webprofile/backend/setting/index.blade.php new file mode 100644 index 0000000..107fbd3 --- /dev/null +++ b/resources/views/webprofile/backend/setting/index.blade.php @@ -0,0 +1,60 @@ +@extends('webprofile.backend.layouts.master') + +@section('title') + {{ $title }} +@stop + +@section('breadcrumbs') +<li><a href="{{ url('dashboard') }}">@lang('label.dashboard')</a></li> +<li class="active">@lang('feature.setting')</li> +@stop + +@section('content') +<!-- page start--> +<div class="row"> + <div class="col-lg-12"> + <!-- START DEFAULT DATATABLE --> + <div class="panel panel-default"> + <div class="panel-heading"> + <h3 class="panel-title">{!! $title !!}</h3> + {{-- <a class="btn btn-info" href="{{URL::to('webprofile/settings/create')}}" style="margin: 0cm 0px 0cm 10px;">@lang('label.create')</a> --}} + <ul class="panel-controls"> + <li><a href="#" class="panel-collapse"><span class="fa fa-angle-down"></span></a></li> + </ul> + </div> + <div class="panel-body"> + <table class="table datatable table-hover" id="berita"> + <thead> + <tr> + <th width="7%">@lang('label.number')</th> + <th width="33%">@lang('label.name')</th> + <th width="30%">@lang('label.value')</th> + <th align="center" width="15%">@lang('label.action')</th> + </tr> + </thead> + <tbody> + <?php $no = 1;?> + @foreach($data as $value) + <tr style="cursor:pointer"> + <td align="center"><?php echo $no; ?></td> + <td>{!! $value->name_setting !!}</td> + <td>{!! $value->value_setting !!}</td> + <td style="text-align:center;"> + <a href="{{ route('settings.edit', ['data'=>Crypt::encrypt($value->id)]) }}" class="btn btn-warning btn-xs"><i class="fa fa-pencil"></i></a> + </td> + <?php $no++;?> + </tr> + @endforeach + </tbody> + </table> + </div> + </div> + <!-- END DEFAULT DATATABLE --> + </div> +</div> +<!-- page end--> +@stop + +@section('script') +<script src="{!!asset('backend/js/datatables.net/js/jquery.dataTables.min.js') !!}"></script> +@stop diff --git a/routes/webprofile/backend.php b/routes/webprofile/backend.php index 106d5c3..664fc6f 100644 --- a/routes/webprofile/backend.php +++ b/routes/webprofile/backend.php @@ -6,6 +6,7 @@ Route::group(['middleware' => 'auth'], function () { Route::resource('posts', 'PostController'); Route::resource('pages', 'PageController'); Route::resource('informations', 'InformationController'); + Route::resource('settings', 'SettingController'); }); // }); }); -- libgit2 0.26.0