diff --git a/app/Http/Controllers/Admin/Apps/FormController.php b/app/Http/Controllers/Admin/Apps/FormController.php new file mode 100644 index 0000000..6ef04b7 --- /dev/null +++ b/app/Http/Controllers/Admin/Apps/FormController.php @@ -0,0 +1,52 @@ +route('apps'), 'Register New Application'=>'']; + $title = 'Register New Application'; + return view('Admin.Apps.create') + ->with('breadcrumb', $breadcrumb) + ->with('title', $title); + } + /** + * Store data + * @param void object laravel Request + * @return string json + */ + public function store(Request $r) + { + //validate before saving + $validation = \Validator::make($r->all(),[ + 'name'=>'required', + 'url'=>'required',]); + + if ($validation->fails()) + return response()->json(['errors'=>$validation->errors()], 422); + $apps = new Apps; + $apps->name = $r->input('name'); + $apps->parent = $r->input('parent'); + $apps->node_name = $r->input('node_name'); + $apps->url = $r->input('url'); + $apps->color = $r->input('color'); + $apps->icon = $r->input('icon'); + $apps->desc = $r->input('desc'); + $apps->sorter = $r->input('sorter'); + $apps->save(); + + return response()->json(['status'=>'success']); + } + +} diff --git a/app/Http/Controllers/Admin/Apps/IndexController.php b/app/Http/Controllers/Admin/Apps/IndexController.php new file mode 100644 index 0000000..d57301d --- /dev/null +++ b/app/Http/Controllers/Admin/Apps/IndexController.php @@ -0,0 +1,37 @@ +'']; + $title = 'Application Management'; + return view('Admin.Apps.index') + ->with('title', $title) + ->with('breadcrumb', $breadcrumb); + } + /** + * Getting list of registered Application + */ + public function getList(Request $r) + { + $apps = Apps::where('name', 'like', '%'.$r->input('name').'%') + ->get(); + if (is_object($apps) && count($apps)>0) + return response()->json(['status'=>'success', 'd'=>$apps]); + else + return response()->json(['status'=>'fail']); + } +} diff --git a/app/Http/Controllers/Admin/Profile/FormController.php b/app/Http/Controllers/Admin/Profile/FormController.php index 07fea70..168db08 100644 --- a/app/Http/Controllers/Admin/Profile/FormController.php +++ b/app/Http/Controllers/Admin/Profile/FormController.php @@ -21,8 +21,8 @@ public function store(Request $r) $validation =\Validator::make($r->all(), [ 'name'=>'required|max:191', 'id'=>'required', - 'username'=>'required', - 'email'=>'required|email', + 'username'=>'required|alpha_dash', + 'email'=>'required|email|unique:users,email,'.$r->input('id'), 'avatar'=>'image|max:1024']); //check validataion result if ($validation->fails()) @@ -79,7 +79,7 @@ private function moveFile($file, $filename, $path, $user) if (file_exists($path.$filename)) unlink($path.$filename); //check the existing file refer to exist data - if (file_exists($path.$user->avatar)) + if ($user->avatar!="" && file_exists($path.$user->avatar)) unlink($path.$user->avatar); //check the existing file refer to exist data (thumbnail) if (file_exists($path.'thumb-'.$user->avatar)) diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index 5c06fd1..d688d83 100644 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -50,7 +50,7 @@ protected function validator(array $data) { return Validator::make($data, [ 'name' => ['required', 'string', 'max:255'], - 'username' => ['required', 'string', 'max:255', 'unique:users'], + 'username' => ['required', 'string', 'alpha_dash ', 'max:255', 'unique:users'], 'email' => ['required', 'string', 'email', 'max:255', 'unique:users'], 'password' => ['required', 'string', 'min:8', 'confirmed'], ]); diff --git a/app/Models/Apps.php b/app/Models/Apps.php new file mode 100644 index 0000000..54db45f --- /dev/null +++ b/app/Models/Apps.php @@ -0,0 +1,10 @@ +bigIncrements('id'); + $table->bigInteger('parent')->nullable(); + $table->integer('sorter')->nullable(); + $table->string('name'); + $table->string('node_name')->nullable(); + $table->mediumText('desc')->nullable(); + $table->string('url'); + $table->string('color')->nullable(); + $table->string('icon')->nullable(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('apps'); + } +} diff --git a/public/assets/Admin/Apps/create.js b/public/assets/Admin/Apps/create.js new file mode 100644 index 0000000..522bffd --- /dev/null +++ b/public/assets/Admin/Apps/create.js @@ -0,0 +1,32 @@ +/** + * initialize event on creating menu management features + */ +var init = function(){ + $('#app-form').submit(function(e){ + e.preventDefault(); + saveApps(); + }); +} +var saveApps = function(){ + if ($('#app-form').postValidate()===false){ + return false; + } + $('#app-form').postAjax({ + success:function(r){ + console.log(r); + if (r.status=="success"){ + iziToast.success({ + title: 'INFO !', + message: 'Operation success, data has been saved', + position: 'topRight' + }); + }else{ + iziToast.error({ + title: 'INFO !', + message: 'Operation failed, please check the data input', + position: 'topRight' + }); + } + } + }); +} \ No newline at end of file diff --git a/public/assets/Admin/Apps/index.js b/public/assets/Admin/Apps/index.js new file mode 100644 index 0000000..4e84721 --- /dev/null +++ b/public/assets/Admin/Apps/index.js @@ -0,0 +1,60 @@ +/** + * Initial event + */ +var init = function(){ + $('#app-index').submit(function(e){ + e.preventDefault(); + displayIndex(); + }); +} +/** + * displaying list of registered application + */ +var displayIndex = function(){ + $('#app-index').postAjax({ + success:function(r){ + + if (r.status=="success"){ + injectTable(r.d); + }else{ + iziToast.error({ + title: 'Not Found !', + message: 'Please try other keywords', + position: 'topRight' + }); + } + } + }); +} + +var injectTable = function(obj){ + + var tr = ""; + var td = $('#table-apps thead tr th'); + var tbody = $('#table-apps tbody'); + $.each(obj, function(i, v) { + datas = ""; + $.each(v, function(id, iv) { + datas += 'data-' + id + '="' + iv + '"'; + }); + tr += ""; + $.each(td, function(index, field) { + tr += ""; + if ($(this).data('field')=='icon'){ + if (v[$(this).data('field')]==null) + tr += ""; + else + tr += ""; + }else{ + if (v[$(this).data('field')]==null) + tr += '-'; + else + tr += v[$(this).data('field')]; + } + + tr += ""; + }); + tr += ""; + }); + tbody.html(tr); +} \ No newline at end of file diff --git a/resources/views/Admin/Apps/create.blade.php b/resources/views/Admin/Apps/create.blade.php new file mode 100644 index 0000000..53d90ec --- /dev/null +++ b/resources/views/Admin/Apps/create.blade.php @@ -0,0 +1,242 @@ +@extends('layouts.master-admin') +@section('component') + @component('layouts.elements.others.with-header', + ['title'=>'Application Management', + 'subtitle'=>'Create / Update Menu', + 'desc'=>'Page for registering / updating application information', + 'breadcrumb'=> (isset($breadcrumb)?$breadcrumb:'')]) +
+ @csrf + @component('layouts.elements.others.card', + ['title'=>'Application / Menu Configuration']) +

General settings such as name, photo profile, etc

+
+ +
+ +
+ @if ($errors->has('name')) + {{ $errors->first('name') }} + @else + {{__('Please fill in application / menu name')}} + @endif +
+
+
+ +
+ @if ($errors->has('id')) + {{ $errors->first('id') }} + @endif +
+
+
+
+ +
+ +
+ @if ($errors->has('parent')) + {{ $errors->first('parent') }} + @else + {{__('Please fill in menu parent')}} + @endif +
+
+
+
+ +
+ +
+ @if ($errors->has('sorter')) + {{ $errors->first('sorter') }} + @endif +
+
+
+
+ +
+ +
+ @if ($errors->has('node_name')) + {{ $errors->first('node_name') }} + @endif +
+
+
+
+ +
+ +
+ @if ($errors->has('url')) + {{ $errors->first('url') }} + @else + {{__('Please fill in Url / Link Application')}} + @endif +
+
+
+
+ +
+ +
+ @if ($errors->has('color')) + {{ $errors->first('color') }} + @endif +
+
+
+
+ +
+ +
+ @if ($errors->has('icon')) + {{ $errors->first('icon') }} + @endif +
+
+
+
+ +
+ +
+ @if ($errors->has('desc')) + {{ $errors->first('desc') }} + @endif +
+
+
+ @slot('footer') +
+ +
+ @endslot + @endcomponent +
+ + @endcomponent +@endsection +@section('scripts') + + + + +@endsection +@section('css') + +@endsection \ No newline at end of file diff --git a/resources/views/Admin/Apps/index.blade.php b/resources/views/Admin/Apps/index.blade.php new file mode 100644 index 0000000..20da52f --- /dev/null +++ b/resources/views/Admin/Apps/index.blade.php @@ -0,0 +1,85 @@ +@extends('layouts.master-admin') +@section('component') + @component('layouts.elements.others.with-header', + ['title'=>'Application Management', + 'subtitle'=>'Application List', + 'desc'=>'Page for doing some operation like register, update, delete Application, manage menu', + 'breadcrumb'=> (isset($breadcrumb)?$breadcrumb:'')]) + @component('layouts.elements.others.card', + ['title'=>'Application List']) +

Write the keywords bellow to display list of registered application

+ @slot('header_action') +   Add  + @endslot +
+ @csrf +
+ +
+ +
+
+
+ +
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Icon + NameURL LinkSorterDesc
+
+
Redesign homepage + Apps/test + + 1 + 2018-04-10
+
+
Redesign homepage + Apps/test + + 1 + 2018-04-10
+ + @slot('footer')@endslot + @endcomponent + @endcomponent +@endsection +@section('scripts') + + + +@endsection \ No newline at end of file diff --git a/resources/views/Admin/Profile/menu-setting.blade.php b/resources/views/Admin/Profile/menu-setting.blade.php index edecc86..a012bd2 100644 --- a/resources/views/Admin/Profile/menu-setting.blade.php +++ b/resources/views/Admin/Profile/menu-setting.blade.php @@ -3,7 +3,7 @@
imageavatar)?asset('files/admin/users/thumb-'.\Auth::user()->avatar):asset('assets/img/avatar/avatar-1.png')}}" class="rounded-circle author-box-picture" style="width:100px;">
diff --git a/resources/views/auth/register.blade.php b/resources/views/auth/register.blade.php index 9fe7d2c..4396d19 100644 --- a/resources/views/auth/register.blade.php +++ b/resources/views/auth/register.blade.php @@ -26,7 +26,7 @@
- +
@if ($errors->has('username')) {{ $errors->first('username') }} diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php index c181488..2866df4 100644 --- a/resources/views/layouts/app.blade.php +++ b/resources/views/layouts/app.blade.php @@ -5,7 +5,7 @@ - {{ config('app.name', 'Laravel') }} + {{ (isset($title) && $title!=''?$title:config('app.name', 'Laravel')) }} diff --git a/resources/views/layouts/elements/others/card.blade.php b/resources/views/layouts/elements/others/card.blade.php index b561608..fbb4ba8 100644 --- a/resources/views/layouts/elements/others/card.blade.php +++ b/resources/views/layouts/elements/others/card.blade.php @@ -8,8 +8,13 @@ @ component('layouts.elements.others.card', ['title'=>'Your Title']) @endif + @if (isset($header_action)) +
+ {{$header_action}} +
+ @endif
-
+
{{$slot}}
@if (isset($footer)) diff --git a/routes/web.php b/routes/web.php index 28f921c..879c65f 100644 --- a/routes/web.php +++ b/routes/web.php @@ -20,8 +20,15 @@ * Grouping all the route that need authentication to access it */ Route::group(['middleware' => 'auth'], function() { + Route::get('profile', 'Admin\Profile\IndexController@index')->name('profile'); Route::get('profile/setting', 'Admin\Profile\IndexController@setting')->name('profile-setting'); Route::post('profile/store', 'Admin\Profile\FormController@store')->name('profile-store'); Route::post('profile/password', 'Admin\Profile\PwdController@change')->name('profile-change-pwd'); + + Route::get('apps', 'Admin\Apps\IndexController@index')->name('apps'); + Route::get('apps/create', 'Admin\Apps\FormController@create')->name('apps.create'); + Route::post('apps/ajax/store', 'Admin\Apps\FormController@store')->name('apps.ajax.store'); + Route::post('apps/ajax/getList', 'Admin\Apps\IndexController@getList')->name('apps.ajax.getList'); + });