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 += "
Write the keywords bellow to display list of registered application
+ @slot('header_action') + Add + @endslot + ++ Icon + | +Name | +URL Link | +Sorter | +Desc | +
---|---|---|---|---|
+
+ |
+ Redesign homepage | ++ Apps/test + | ++ 1 + | +2018-04-10 | +
+
+ |
+ Redesign homepage | ++ Apps/test + | ++ 1 + | +2018-04-10 | +