From 7a1ba28e3642e1f7dffa74c3cf0d5f5bcfd7bcb2 Mon Sep 17 00:00:00 2001 From: Akram Date: Sat, 11 May 2024 22:59:40 +0530 Subject: [PATCH] Adding Breadcrumb --- .../Commands/stubs/module/controller.stub | 12 + .../Commands/stubs/module/views/index.stub | 1 + .../Commands/stubs/module/views/manage.stub | 1 + .../Controllers/Admin/ModuleController.php | 16 +- app/Http/Controllers/Admin/PageController.php | 304 +++++++------- .../Controllers/Admin/SettingController.php | 301 +++++++------- app/Http/Controllers/HomeController.php | 55 +-- app/Http/Controllers/IndexController.php | 26 +- app/Http/Controllers/RoleController.php | 276 +++++++------ app/Http/Controllers/SettingController.php | 63 --- app/Http/Controllers/TestController.php | 15 +- app/Http/Controllers/UserController.php | 389 +++++++++--------- resources/views/backend/home.blade.php | 1 + .../layouts/partial/breadcrumb.blade.php | 22 + .../views/backend/modules/index.blade.php | 1 + resources/views/backend/pages/index.blade.php | 1 + .../views/backend/pages/manage.blade.php | 1 + resources/views/backend/roles/index.blade.php | 1 + .../views/backend/roles/manage.blade.php | 1 + .../views/backend/settings/general.blade.php | 1 + .../views/backend/settings/index.blade.php | 1 + .../views/backend/settings/manage.blade.php | 1 + resources/views/backend/users/index.blade.php | 1 + .../views/backend/users/manage.blade.php | 1 + routes/web.php | 4 +- 25 files changed, 757 insertions(+), 739 deletions(-) delete mode 100644 app/Http/Controllers/SettingController.php create mode 100644 resources/views/backend/layouts/partial/breadcrumb.blade.php diff --git a/app/Console/Commands/stubs/module/controller.stub b/app/Console/Commands/stubs/module/controller.stub index 03b8397..3b67f24 100644 --- a/app/Console/Commands/stubs/module/controller.stub +++ b/app/Console/Commands/stubs/module/controller.stub @@ -22,6 +22,10 @@ class {CONTROLLER_NAME} extends Controller { 'create_route' => route('admin.' . $this->handle_name_plural . '.create'), 'table_status' => 'all', //all , trashed 'all_count' => $all_count, + 'module_names' => [ + 'singular' => $this->handle_name, + 'plural' => $this->handle_name_plural, + ], 'trashed_count' => $trashed_count, ]); } @@ -29,12 +33,20 @@ class {CONTROLLER_NAME} extends Controller { return kview($this->handle_name_plural . '.manage', [ 'form_action' => route('admin.' . $this->handle_name_plural . '.store'), 'edit' => 0, + 'module_names' => [ + 'singular' => $this->handle_name, + 'plural' => $this->handle_name_plural, + ], ]); } public function edit(Request $request) { return kview($this->handle_name_plural . '.manage', [ 'form_action' => route('admin.' . $this->handle_name_plural . '.update'), 'edit' => 1, + 'module_names' => [ + 'singular' => $this->handle_name, + 'plural' => $this->handle_name_plural, + ], 'data' => Table::where('id', '=', $request->id)->first(), ]); } diff --git a/app/Console/Commands/stubs/module/views/index.stub b/app/Console/Commands/stubs/module/views/index.stub index 3f29bae..14c909d 100644 --- a/app/Console/Commands/stubs/module/views/index.stub +++ b/app/Console/Commands/stubs/module/views/index.stub @@ -5,6 +5,7 @@ $page_number = 1; ?>
+ @include($theme_name.'.layouts.partial.breadcrumb')
@if ($errors->any())
diff --git a/app/Console/Commands/stubs/module/views/manage.stub b/app/Console/Commands/stubs/module/views/manage.stub index 646e55b..d5af82f 100644 --- a/app/Console/Commands/stubs/module/views/manage.stub +++ b/app/Console/Commands/stubs/module/views/manage.stub @@ -2,6 +2,7 @@ @section('content')
+ @include($theme_name.'.layouts.partial.breadcrumb')
@if ($errors->any())
diff --git a/app/Http/Controllers/Admin/ModuleController.php b/app/Http/Controllers/Admin/ModuleController.php index bd34609..f497ecb 100644 --- a/app/Http/Controllers/Admin/ModuleController.php +++ b/app/Http/Controllers/Admin/ModuleController.php @@ -25,6 +25,10 @@ public function index() { 'create_route' => route('admin.' . $this->handle_name_plural . '.create'), 'table_status' => 'all', //all , trashed 'all_count' => $all_count, + 'module_names' => [ + 'singular' => $this->handle_name, + 'plural' => $this->handle_name_plural, + ], 'trashed_count' => $trashed_count, ]); } @@ -33,7 +37,11 @@ public function create() { $form_action = route('admin.modules.store'); $col_types = getColumnTypes(); $edit = 0; - return kview($this->handle_name_plural . '.manage', compact('form_action', 'col_types', 'edit')); + $module_names = [ + 'singular' => $this->handle_name, + 'plural' => $this->handle_name_plural, + ]; + return kview($this->handle_name_plural . '.manage', compact('form_action', 'module_names', 'col_types', 'edit')); } public function edit(Request $request) { @@ -42,9 +50,13 @@ public function edit(Request $request) { $col_types = getColumnTypes(); $data = Table::where('id', '=', $request->id)->first(); $edit = 0; + $module_names = [ + 'singular' => $this->handle_name, + 'plural' => $this->handle_name_plural, + ]; return kview( $this->handle_name_plural . '.manage', - compact('form_action', 'col_types', 'data', 'edit') + compact('form_action', 'col_types', 'module_names', 'data', 'edit') ); } diff --git a/app/Http/Controllers/Admin/PageController.php b/app/Http/Controllers/Admin/PageController.php index 3b79122..9dae1c8 100644 --- a/app/Http/Controllers/Admin/PageController.php +++ b/app/Http/Controllers/Admin/PageController.php @@ -10,164 +10,176 @@ use Illuminate\Http\Request; class PageController extends Controller { - protected $handle_name = "page"; - protected $handle_name_plural = "pages"; + protected $handle_name = "page"; + protected $handle_name_plural = "pages"; - public function index() { - $all_count = Table::count(); - $trashed_count = Table::onlyTrashed()->count(); - return kview($this->handle_name_plural . '.index', [ - 'ajax_route' => route('admin.' . $this->handle_name_plural . '.ajax'), - 'delete_route' => route('admin.' . $this->handle_name_plural . '.delete'), - 'create_route' => route('admin.' . $this->handle_name_plural . '.create'), - 'table_status' => 'all', //all , trashed - 'all_count' => $all_count, - 'trashed_count' => $trashed_count, - ]); - } - public function create() { - return kview($this->handle_name_plural . '.manage', [ - 'form_action' => route('admin.' . $this->handle_name_plural . '.store'), - 'edit' => 0, - ]); - } - public function edit(Request $request) { - return kview($this->handle_name_plural . '.manage', [ - 'form_action' => route('admin.' . $this->handle_name_plural . '.update'), - 'edit' => 1, - 'data' => Table::where('id', '=', $request->id)->first(), - ]); - } - public function store(AddRequest $request) { - try { + public function index() { + $all_count = Table::count(); + $trashed_count = Table::onlyTrashed()->count(); + return kview($this->handle_name_plural . '.index', [ + 'ajax_route' => route('admin.' . $this->handle_name_plural . '.ajax'), + 'delete_route' => route('admin.' . $this->handle_name_plural . '.delete'), + 'create_route' => route('admin.' . $this->handle_name_plural . '.create'), + 'table_status' => 'all', //all , trashed + 'all_count' => $all_count, + 'module_names' => [ + 'singular' => $this->handle_name, + 'plural' => $this->handle_name_plural, + ], + 'trashed_count' => $trashed_count, + ]); + } + public function create() { + return kview($this->handle_name_plural . '.manage', [ + 'form_action' => route('admin.' . $this->handle_name_plural . '.store'), + 'edit' => 0, + 'module_names' => [ + 'singular' => $this->handle_name, + 'plural' => $this->handle_name_plural, + ], + ]); + } + public function edit(Request $request) { + return kview($this->handle_name_plural . '.manage', [ + 'form_action' => route('admin.' . $this->handle_name_plural . '.update'), + 'edit' => 1, + 'data' => Table::where('id', '=', $request->id)->first(), + 'module_names' => [ + 'singular' => $this->handle_name, + 'plural' => $this->handle_name_plural, + ], + ]); + } + public function store(AddRequest $request) { + try { - $table = Table::create([ - 'name' => $request->name, - ]); + $table = Table::create([ + 'name' => $request->name, + ]); - return redirect()->to(route('admin.' . $this->handle_name_plural . '.index'))->with('success', 'New ' . ucfirst($this->handle_name) . ' has been added.'); - } catch (Exception $e) { - return $e->getMessage(); - return redirect()->back()->with('error', $e->getMessage()); - } + return redirect()->to(route('admin.' . $this->handle_name_plural . '.index'))->with('success', 'New ' . ucfirst($this->handle_name) . ' has been added.'); + } catch (Exception $e) { + return $e->getMessage(); + return redirect()->back()->with('error', $e->getMessage()); } - public function update(UpdateRequest $request) { - try { - $update_data = [ - 'name' => $request->name, - ]; - $where = [ - 'id' => $request->id - ]; - Table::updateOrCreate($where, $update_data); + } + public function update(UpdateRequest $request) { + try { + $update_data = [ + 'name' => $request->name, + ]; + $where = [ + 'id' => $request->id + ]; + Table::updateOrCreate($where, $update_data); - return redirect()->back()->with('success', ucfirst($this->handle_name) . ' has been updated'); - } catch (Exception $e) { - return redirect()->back()->with('error', $e->getMessage()); - } + return redirect()->back()->with('success', ucfirst($this->handle_name) . ' has been updated'); + } catch (Exception $e) { + return redirect()->back()->with('error', $e->getMessage()); + } + } + public function ajax(Request $request) { + $edit_route = route('admin.' . $this->handle_name_plural . '.edit'); + $current_page = $request->page_number; + if (isset($request->limit)) { + $limit = $request->limit; + } else { + $limit = 10; + } + $offset = (($current_page - 1) * $limit); + $modalObject = new Table(); + if (isset($request->string)) { + $string = $request->string; + $modalObject = $modalObject->where('name', 'like', "%" . $request->string . "%"); + // $modalObject = $modalObject->orWhere('name','like',"%".$request->string."%"); } - public function ajax(Request $request) { - $edit_route = route('admin.' . $this->handle_name_plural . '.edit'); - $current_page = $request->page_number; - if (isset($request->limit)) { - $limit = $request->limit; - } else { - $limit = 10; - } - $offset = (($current_page - 1) * $limit); - $modalObject = new Table(); - if (isset($request->string)) { - $string = $request->string; - $modalObject = $modalObject->where('name', 'like', "%" . $request->string . "%"); - // $modalObject = $modalObject->orWhere('name','like',"%".$request->string."%"); - } - $all_trashed = $request->all_trashed; - if ($all_trashed == "trashed") { - $modalObject = $modalObject->onlyTrashed(); - } + $all_trashed = $request->all_trashed; + if ($all_trashed == "trashed") { + $modalObject = $modalObject->onlyTrashed(); + } - $total_records = $modalObject->count(); - $modalObject = $modalObject->offset($offset); - $modalObject = $modalObject->take($limit); - $data = $modalObject->get(); + $total_records = $modalObject->count(); + $modalObject = $modalObject->offset($offset); + $modalObject = $modalObject->take($limit); + $data = $modalObject->get(); - if (isset($request->page_number) && $request->page_number != 1) { - $page_number = $request->page_number + $limit - 1; - } else { - $page_number = 1; - } - $pagination = array( - "offset" => $offset, - "total_records" => $total_records, - "item_per_page" => $limit, - "total_pages" => ceil($total_records / $limit), - "current_page" => $current_page, - ); + if (isset($request->page_number) && $request->page_number != 1) { + $page_number = $request->page_number + $limit - 1; + } else { + $page_number = 1; + } + $pagination = array( + "offset" => $offset, + "total_records" => $total_records, + "item_per_page" => $limit, + "total_pages" => ceil($total_records / $limit), + "current_page" => $current_page, + ); - return kview($this->handle_name_plural . '.ajax', compact('edit_route', 'data', 'page_number', 'limit', 'offset', 'pagination')); + return kview($this->handle_name_plural . '.ajax', compact('edit_route', 'data', 'page_number', 'limit', 'offset', 'pagination')); + } + public function delete(Request $request) { + if (isset($request->action)) { + $action = $request->action; + $is_bulk = $request->is_bulk; + $data_id = $request->data_id; } - public function delete(Request $request) { - if (isset($request->action)) { - $action = $request->action; - $is_bulk = $request->is_bulk; - $data_id = $request->data_id; + switch ($action) { + case 'restore': + try { + if ($is_bulk == 1) { + $data_id = explode(",", $data_id); + $table = Table::onlyTrashed()->whereIn('id', $data_id); + $table->restore(); + return 1; + } else { + $table = Table::onlyTrashed()->find($data_id); + $table->restore(); + return 1; + } + } catch (Exception $e) { + return redirect()->back()->with('error', $e->getMessage()); + } + break; + case 'trash': + try { + if ($is_bulk == 1) { + $data_id = explode(",", $data_id); + $table = Table::whereIn('id', $data_id); + $table->delete(); + return 1; + } else { + $table = Table::find($data_id); + $table->delete(); + return 1; + } + } catch (Exception $e) { + return redirect()->back()->with('error', $e->getMessage()); } - switch ($action) { - case 'restore': - try { - if ($is_bulk == 1) { - $data_id = explode(",", $data_id); - $table = Table::onlyTrashed()->whereIn('id', $data_id); - $table->restore(); - return 1; - } else { - $table = Table::onlyTrashed()->find($data_id); - $table->restore(); - return 1; - } - } catch (Exception $e) { - return redirect()->back()->with('error', $e->getMessage()); - } - break; - case 'trash': - try { - if ($is_bulk == 1) { - $data_id = explode(",", $data_id); - $table = Table::whereIn('id', $data_id); - $table->delete(); - return 1; - } else { - $table = Table::find($data_id); - $table->delete(); - return 1; - } - } catch (Exception $e) { - return redirect()->back()->with('error', $e->getMessage()); - } - break; - case 'delete': - try { - if ($is_bulk == 1) { - $data_id = explode(",", $data_id); - $table = Table::withTrashed()->whereIn('id', $data_id)->get(); - foreach ($table as $tbl) { - // $detach_relationship = $tbl->relationship()->detach(); - $tbl->forceDelete(); - } - return 1; - } else { - $table = Table::withTrashed()->find($data_id); - // $detach_relationship = $table->relationship()->detach(); - $data = $table->forceDelete(); - return 1; - } - } catch (Exception $e) { - return redirect()->back()->with('error', $e->getMessage()); - } - break; - default: - return 0; + break; + case 'delete': + try { + if ($is_bulk == 1) { + $data_id = explode(",", $data_id); + $table = Table::withTrashed()->whereIn('id', $data_id)->get(); + foreach ($table as $tbl) { + // $detach_relationship = $tbl->relationship()->detach(); + $tbl->forceDelete(); + } + return 1; + } else { + $table = Table::withTrashed()->find($data_id); + // $detach_relationship = $table->relationship()->detach(); + $data = $table->forceDelete(); + return 1; + } + } catch (Exception $e) { + return redirect()->back()->with('error', $e->getMessage()); } + break; + default: + return 0; } + } } diff --git a/app/Http/Controllers/Admin/SettingController.php b/app/Http/Controllers/Admin/SettingController.php index 7940a7c..691038f 100644 --- a/app/Http/Controllers/Admin/SettingController.php +++ b/app/Http/Controllers/Admin/SettingController.php @@ -28,30 +28,15 @@ public function edit_profile() { return kview('users.manage', [ 'form_action' => route('admin.users.update'), 'edit' => 1, + 'module_names' => [ + 'singular' => $this->handle_name, + 'plural' => $this->handle_name_plural, + ], 'data' => $user, 'roles' => $roles, ]); } - // public function update(Request $request) { - // if (isset($request->SITE_NAME)) { - // $this->updateSetting('SITE_NAME', $request->SITE_NAME); - // } - // if (isset($request->site_url)) { - // $this->updateSetting('site_url', $request->site_url); - // } - // if (isset($request->tagline)) { - // $this->updateSetting('tagline', $request->tagline); - // } - // if (isset($request->instagram_cookie)) { - // $this->updateSetting('instagram_cookie', $request->instagram_cookie); - // } - // if (isset($request->theme)) { - // $this->updateSetting('theme', $request->theme); - // } - // return redirect()->back()->with('success', 'Settings has been updated'); - // } - public function updateSetting($key, $value) { $where = [ 'key' => $key, @@ -66,158 +51,170 @@ public function index() { $all_count = Table::count(); $trashed_count = Table::onlyTrashed()->count(); return kview($this->handle_name_plural . '.index', [ - 'ajax_route' => route('admin.' . $this->handle_name_plural . '.ajax'), - 'delete_route' => route('admin.' . $this->handle_name_plural . '.delete'), - 'create_route' => route('admin.' . $this->handle_name_plural . '.create'), - 'table_status' => 'all', //all , trashed - 'all_count' => $all_count, - 'trashed_count' => $trashed_count, + 'ajax_route' => route('admin.' . $this->handle_name_plural . '.ajax'), + 'delete_route' => route('admin.' . $this->handle_name_plural . '.delete'), + 'create_route' => route('admin.' . $this->handle_name_plural . '.create'), + 'table_status' => 'all', //all , trashed + 'all_count' => $all_count, + 'module_names' => [ + 'singular' => $this->handle_name, + 'plural' => $this->handle_name_plural, + ], + 'trashed_count' => $trashed_count, ]); } public function create() { - return kview($this->handle_name_plural . '.manage', [ - 'form_action' => route('admin.' . $this->handle_name_plural . '.store'), - 'edit' => 0, - ]); + return kview($this->handle_name_plural . '.manage', [ + 'form_action' => route('admin.' . $this->handle_name_plural . '.store'), + 'edit' => 0, + 'module_names' => [ + 'singular' => $this->handle_name, + 'plural' => $this->handle_name_plural, + ], + ]); } public function edit(Request $request) { - return kview($this->handle_name_plural . '.manage', [ - 'form_action' => route('admin.' . $this->handle_name_plural . '.update'), - 'edit' => 1, - 'data' => Table::where('id', '=', $request->id)->first(), - ]); + return kview($this->handle_name_plural . '.manage', [ + 'form_action' => route('admin.' . $this->handle_name_plural . '.update'), + 'edit' => 1, + 'module_names' => [ + 'singular' => $this->handle_name, + 'plural' => $this->handle_name_plural, + ], + 'data' => Table::where('id', '=', $request->id)->first(), + ]); } public function store(Request $request) { - try { + try { - $table = Table::create([ - 'key' => $request->key, - 'value' => $request->value, - ]); + $table = Table::create([ + 'key' => $request->key, + 'value' => $request->value, + ]); - return redirect()->to(route('admin.' . $this->handle_name_plural . '.index'))->with('success', 'New ' . ucfirst($this->handle_name) . ' has been added.'); - } catch (Exception $e) { - return $e->getMessage(); - return redirect()->back()->with('error', $e->getMessage()); - } + return redirect()->to(route('admin.' . $this->handle_name_plural . '.index'))->with('success', 'New ' . ucfirst($this->handle_name) . ' has been added.'); + } catch (Exception $e) { + return $e->getMessage(); + return redirect()->back()->with('error', $e->getMessage()); + } } public function update(Request $request) { - try { - $update_data = [ - 'key' => $request->key, - 'value' => $request->value, - ]; - $where = [ - 'id' => $request->id - ]; - Table::updateOrCreate($where, $update_data); + try { + $update_data = [ + 'key' => $request->key, + 'value' => $request->value, + ]; + $where = [ + 'id' => $request->id + ]; + Table::updateOrCreate($where, $update_data); - return redirect()->to(route('admin.' . $this->handle_name_plural . '.index'))->with('success', 'New ' . ucfirst($this->handle_name) . ' has been added.'); - } catch (Exception $e) { - return redirect()->back()->with('error', $e->getMessage()); - } + return redirect()->to(route('admin.' . $this->handle_name_plural . '.index'))->with('success', 'New ' . ucfirst($this->handle_name) . ' has been added.'); + } catch (Exception $e) { + return redirect()->back()->with('error', $e->getMessage()); + } } public function ajax(Request $request) { - $edit_route = route('admin.' . $this->handle_name_plural . '.edit'); - $current_page = $request->page_number; - if (isset($request->limit)) { - $limit = $request->limit; - } else { - $limit = 10; - } - $offset = (($current_page - 1) * $limit); - $modalObject = new Table(); - if (isset($request->string)) { - $string = $request->string; - $modalObject = $modalObject->where('key', 'like', "%" . $request->string . "%"); - } + $edit_route = route('admin.' . $this->handle_name_plural . '.edit'); + $current_page = $request->page_number; + if (isset($request->limit)) { + $limit = $request->limit; + } else { + $limit = 10; + } + $offset = (($current_page - 1) * $limit); + $modalObject = new Table(); + if (isset($request->string)) { + $string = $request->string; + $modalObject = $modalObject->where('key', 'like', "%" . $request->string . "%"); + } - $all_trashed = $request->all_trashed; - if ($all_trashed == "trashed") { - $modalObject = $modalObject->onlyTrashed(); - } + $all_trashed = $request->all_trashed; + if ($all_trashed == "trashed") { + $modalObject = $modalObject->onlyTrashed(); + } - $total_records = $modalObject->count(); - $modalObject = $modalObject->offset($offset); - $modalObject = $modalObject->take($limit); - $data = $modalObject->get(); + $total_records = $modalObject->count(); + $modalObject = $modalObject->offset($offset); + $modalObject = $modalObject->take($limit); + $data = $modalObject->get(); - if (isset($request->page_number) && $request->page_number != 1) { - $page_number = $request->page_number + $limit - 1; - } else { - $page_number = 1; - } - $pagination = array( - "offset" => $offset, - "total_records" => $total_records, - "item_per_page" => $limit, - "total_pages" => ceil($total_records / $limit), - "current_page" => $current_page, - ); + if (isset($request->page_number) && $request->page_number != 1) { + $page_number = $request->page_number + $limit - 1; + } else { + $page_number = 1; + } + $pagination = array( + "offset" => $offset, + "total_records" => $total_records, + "item_per_page" => $limit, + "total_pages" => ceil($total_records / $limit), + "current_page" => $current_page, + ); - return kview($this->handle_name_plural . '.ajax', compact('edit_route', 'data', 'page_number', 'limit', 'offset', 'pagination')); + return kview($this->handle_name_plural . '.ajax', compact('edit_route', 'data', 'page_number', 'limit', 'offset', 'pagination')); } public function delete(Request $request) { - if (isset($request->action)) { - $action = $request->action; - $is_bulk = $request->is_bulk; - $data_id = $request->data_id; - } - switch ($action) { - case 'restore': - try { - if ($is_bulk == 1) { - $data_id = explode(",", $data_id); - $table = Table::onlyTrashed()->whereIn('id', $data_id); - $table->restore(); - return 1; - } else { - $table = Table::onlyTrashed()->find($data_id); - $table->restore(); - return 1; - } - } catch (Exception $e) { - return redirect()->back()->with('error', $e->getMessage()); - } - break; - case 'trash': - try { - if ($is_bulk == 1) { - $data_id = explode(",", $data_id); - $table = Table::whereIn('id', $data_id); - $table->delete(); - return 1; - } else { - $table = Table::find($data_id); - $table->delete(); - return 1; - } - } catch (Exception $e) { - return redirect()->back()->with('error', $e->getMessage()); - } - break; - case 'delete': - try { - if ($is_bulk == 1) { - $data_id = explode(",", $data_id); - $table = Table::withTrashed()->whereIn('id', $data_id)->get(); - foreach ($table as $tbl) { - // $detach_relationship = $tbl->relationship()->detach(); - $tbl->forceDelete(); - } - return 1; - } else { - $table = Table::withTrashed()->find($data_id); - // $detach_relationship = $table->relationship()->detach(); - $data = $table->forceDelete(); - return 1; - } - } catch (Exception $e) { - return redirect()->back()->with('error', $e->getMessage()); - } - break; - default: - return 0; - } + if (isset($request->action)) { + $action = $request->action; + $is_bulk = $request->is_bulk; + $data_id = $request->data_id; + } + switch ($action) { + case 'restore': + try { + if ($is_bulk == 1) { + $data_id = explode(",", $data_id); + $table = Table::onlyTrashed()->whereIn('id', $data_id); + $table->restore(); + return 1; + } else { + $table = Table::onlyTrashed()->find($data_id); + $table->restore(); + return 1; + } + } catch (Exception $e) { + return redirect()->back()->with('error', $e->getMessage()); + } + break; + case 'trash': + try { + if ($is_bulk == 1) { + $data_id = explode(",", $data_id); + $table = Table::whereIn('id', $data_id); + $table->delete(); + return 1; + } else { + $table = Table::find($data_id); + $table->delete(); + return 1; + } + } catch (Exception $e) { + return redirect()->back()->with('error', $e->getMessage()); + } + break; + case 'delete': + try { + if ($is_bulk == 1) { + $data_id = explode(",", $data_id); + $table = Table::withTrashed()->whereIn('id', $data_id)->get(); + foreach ($table as $tbl) { + // $detach_relationship = $tbl->relationship()->detach(); + $tbl->forceDelete(); + } + return 1; + } else { + $table = Table::withTrashed()->find($data_id); + // $detach_relationship = $table->relationship()->detach(); + $data = $table->forceDelete(); + return 1; + } + } catch (Exception $e) { + return redirect()->back()->with('error', $e->getMessage()); + } + break; + default: + return 0; + } } } diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 459b3d7..870c5a4 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -6,34 +6,35 @@ use App\Models\User; use App\Providers\RouteServiceProvider; -class HomeController extends Controller -{ - /** - * Create a new controller instance. - * - * @return void - */ - public function __construct() - { - $this->middleware('auth'); - } +class HomeController extends Controller { + /** + * Create a new controller instance. + * + * @return void + */ + public function __construct() { + $this->middleware('auth'); + } - /** - * Show the application dashboard. - * - * @return \Illuminate\Contracts\Support\Renderable - */ - public function index() - { + /** + * Show the application dashboard. + * + * @return \Illuminate\Contracts\Support\Renderable + */ + public function index() { - // Preparing count for Dashboard Array - $users = User::count(); + // Preparing count for Dashboard Array + $users = User::count(); - // Preparing Dashboard card Array. - $dashboard_cards = [ - ['Users', $users, Route('admin.users.index'),'fa fa-dashboard'], - // ['News', $news, 'news.index'], - ]; - return kview('home',compact('dashboard_cards')); - } + // Preparing Dashboard card Array. + $dashboard_cards = [ + ['Users', $users, Route('admin.users.index'), 'fa fa-dashboard'], + // ['News', $news, 'news.index'], + ]; + $module_names = [ + 'singular' => 'dashboard', + 'plural' => 'dashboard', + ]; + return kview('home', compact('dashboard_cards', 'module_names')); + } } diff --git a/app/Http/Controllers/IndexController.php b/app/Http/Controllers/IndexController.php index d79b45f..2673e02 100644 --- a/app/Http/Controllers/IndexController.php +++ b/app/Http/Controllers/IndexController.php @@ -5,18 +5,18 @@ use Illuminate\Http\Request; class IndexController extends Controller { - /** - * Create a new controller instance. - * - * @return void - */ + /** + * Create a new controller instance. + * + * @return void + */ - /** - * Show the application dashboard. - * - * @return \Illuminate\Contracts\Support\Renderable - */ - public function index() { - return view('welcome'); - } + /** + * Show the application dashboard. + * + * @return \Illuminate\Contracts\Support\Renderable + */ + public function index() { + return view('welcome'); + } } diff --git a/app/Http/Controllers/RoleController.php b/app/Http/Controllers/RoleController.php index 0118eb9..1cf9679 100644 --- a/app/Http/Controllers/RoleController.php +++ b/app/Http/Controllers/RoleController.php @@ -9,153 +9,165 @@ use Auth; class RoleController extends Controller { - protected $handle_name = "role"; - protected $handle_name_plural = "roles"; + protected $handle_name = "role"; + protected $handle_name_plural = "roles"; - public function index() { - $all_count = Table::count(); - return kview($this->handle_name_plural . '.index', [ - 'ajax_route' => route('admin.' . $this->handle_name_plural . '.ajax'), - 'delete_route' => route('admin.' . $this->handle_name_plural . '.delete'), - 'create_route' => route('admin.' . $this->handle_name_plural . '.create'), - 'all_count' => $all_count, - ]); - } - public function create() { - return kview($this->handle_name_plural . '.manage', [ - 'form_action' => route('admin.' . $this->handle_name_plural . '.store'), - 'edit' => 0, - ]); - } - public function edit(Request $request) { - return kview($this->handle_name_plural . '.manage', [ - 'form_action' => route('admin.' . $this->handle_name_plural . '.update'), - 'edit' => 1, - 'data' => Table::where('id', '=', $request->id)->first(), - ]); - } - public function store(Request $request) { - try { - $role = Table::create([ - 'name' => $request->name, - ]); + public function index() { + $all_count = Table::count(); + return kview($this->handle_name_plural . '.index', [ + 'ajax_route' => route('admin.' . $this->handle_name_plural . '.ajax'), + 'delete_route' => route('admin.' . $this->handle_name_plural . '.delete'), + 'create_route' => route('admin.' . $this->handle_name_plural . '.create'), + 'module_names' => [ + 'singular' => $this->handle_name, + 'plural' => $this->handle_name_plural, + ], + 'all_count' => $all_count, + ]); + } + public function create() { + return kview($this->handle_name_plural . '.manage', [ + 'form_action' => route('admin.' . $this->handle_name_plural . '.store'), + 'module_names' => [ + 'singular' => $this->handle_name, + 'plural' => $this->handle_name_plural, + ], + 'edit' => 0, + ]); + } + public function edit(Request $request) { + return kview($this->handle_name_plural . '.manage', [ + 'form_action' => route('admin.' . $this->handle_name_plural . '.update'), + 'edit' => 1, + 'module_names' => [ + 'singular' => $this->handle_name, + 'plural' => $this->handle_name_plural, + ], + 'data' => Table::where('id', '=', $request->id)->first(), + ]); + } + public function store(Request $request) { + try { + $role = Table::create([ + 'name' => $request->name, + ]); - $permissions = $request->permissions; - $addPermissions = []; - if ($permissions) { - foreach ($permissions as $key => $value) { - if ($value == "on") { - $existingPermission = Permission::where('name', $key)->count(); - if ($existingPermission == 0) { - Permission::create(['name' => $key]); - } - array_push($addPermissions, $key); - } - } - $role->syncPermissions($addPermissions); + $permissions = $request->permissions; + $addPermissions = []; + if ($permissions) { + foreach ($permissions as $key => $value) { + if ($value == "on") { + $existingPermission = Permission::where('name', $key)->count(); + if ($existingPermission == 0) { + Permission::create(['name' => $key]); } - - return redirect()->to(route('admin.' . $this->handle_name_plural . '.index'))->with('success', 'New ' . ucfirst($this->handle_name) . ' has been added.'); - } catch (Exception $e) { - return redirect()->back()->with('error', $e->getMessage()); + array_push($addPermissions, $key); + } } + $role->syncPermissions($addPermissions); + } + + return redirect()->to(route('admin.' . $this->handle_name_plural . '.index'))->with('success', 'New ' . ucfirst($this->handle_name) . ' has been added.'); + } catch (Exception $e) { + return redirect()->back()->with('error', $e->getMessage()); } - public function update(Request $request) { - try { + } + public function update(Request $request) { + try { - $update_data = [ - 'name' => $request->name, - ]; - $where = [ - 'id' => $request->id - ]; - $role = Table::updateOrCreate($where, $update_data); + $update_data = [ + 'name' => $request->name, + ]; + $where = [ + 'id' => $request->id + ]; + $role = Table::updateOrCreate($where, $update_data); - $permissions = $request->permissions; - $addPermissions = []; - if ($permissions) { - foreach ($permissions as $key => $value) { - if ($value == "on") { - $existingPermission = Permission::where('name', $key)->count(); - if ($existingPermission == 0) { - Permission::create(['name' => $key]); - } - array_push($addPermissions, $key); - } - } - $role->syncPermissions($addPermissions); + $permissions = $request->permissions; + $addPermissions = []; + if ($permissions) { + foreach ($permissions as $key => $value) { + if ($value == "on") { + $existingPermission = Permission::where('name', $key)->count(); + if ($existingPermission == 0) { + Permission::create(['name' => $key]); } - - return redirect()->back()->with('success', ucfirst($this->handle_name) . ' has been updated'); - } catch (Exception $e) { - return redirect()->back()->with('error', $e->getMessage()); + array_push($addPermissions, $key); + } } + $role->syncPermissions($addPermissions); + } + + return redirect()->back()->with('success', ucfirst($this->handle_name) . ' has been updated'); + } catch (Exception $e) { + return redirect()->back()->with('error', $e->getMessage()); + } + } + public function ajax(Request $request) { + $edit_route = route('admin.' . $this->handle_name_plural . '.edit'); + $current_page = $request->page_number; + if (isset($request->limit)) { + $limit = $request->limit; + } else { + $limit = 10; + } + $offset = (($current_page - 1) * $limit); + $modalObject = new Table(); + if (isset($request->string)) { + $string = $request->string; + $modalObject = $modalObject->where('name', 'like', "%" . $request->string . "%"); + // $modalObject = $modalObject->orWhere('name','like',"%".$request->string."%"); } - public function ajax(Request $request) { - $edit_route = route('admin.' . $this->handle_name_plural . '.edit'); - $current_page = $request->page_number; - if (isset($request->limit)) { - $limit = $request->limit; - } else { - $limit = 10; - } - $offset = (($current_page - 1) * $limit); - $modalObject = new Table(); - if (isset($request->string)) { - $string = $request->string; - $modalObject = $modalObject->where('name', 'like', "%" . $request->string . "%"); - // $modalObject = $modalObject->orWhere('name','like',"%".$request->string."%"); - } - $all_trashed = $request->all_trashed; - if ($all_trashed == "trashed") { - $modalObject = $modalObject->onlyTrashed(); - } + $all_trashed = $request->all_trashed; + if ($all_trashed == "trashed") { + $modalObject = $modalObject->onlyTrashed(); + } - $total_records = $modalObject->count(); - $modalObject = $modalObject->offset($offset); - $modalObject = $modalObject->take($limit); - $data = $modalObject->get(); + $total_records = $modalObject->count(); + $modalObject = $modalObject->offset($offset); + $modalObject = $modalObject->take($limit); + $data = $modalObject->get(); - if (isset($request->page_number) && $request->page_number != 1) { - $page_number = $request->page_number + $limit - 1; - } else { - $page_number = 1; - } - $pagination = array( - "offset" => $offset, - "total_records" => $total_records, - "item_per_page" => $limit, - "total_pages" => ceil($total_records / $limit), - "current_page" => $current_page, - ); + if (isset($request->page_number) && $request->page_number != 1) { + $page_number = $request->page_number + $limit - 1; + } else { + $page_number = 1; + } + $pagination = array( + "offset" => $offset, + "total_records" => $total_records, + "item_per_page" => $limit, + "total_pages" => ceil($total_records / $limit), + "current_page" => $current_page, + ); - return kview($this->handle_name_plural . '.ajax', compact('edit_route', 'data', 'page_number', 'limit', 'offset', 'pagination')); + return kview($this->handle_name_plural . '.ajax', compact('edit_route', 'data', 'page_number', 'limit', 'offset', 'pagination')); + } + public function delete(Request $request) { + if (isset($request->action)) { + $action = $request->action; + $is_bulk = $request->is_bulk; + $data_id = $request->data_id; } - public function delete(Request $request) { - if (isset($request->action)) { - $action = $request->action; - $is_bulk = $request->is_bulk; - $data_id = $request->data_id; - } - switch ($action) { - case 'delete': - try { - if ($is_bulk == 1) { - $data_id = explode(",", $data_id); - $table = Table::whereIn('id', $data_id)->delete(); - return 1; - } else { - $table = Table::find($data_id); - $data = $table->delete(); - return 1; - } - } catch (Exception $e) { - return redirect()->back()->with('error', $e->getMessage()); - } - break; - default: - return 0; + switch ($action) { + case 'delete': + try { + if ($is_bulk == 1) { + $data_id = explode(",", $data_id); + $table = Table::whereIn('id', $data_id)->delete(); + return 1; + } else { + $table = Table::find($data_id); + $data = $table->delete(); + return 1; + } + } catch (Exception $e) { + return redirect()->back()->with('error', $e->getMessage()); } + break; + default: + return 0; } + } } diff --git a/app/Http/Controllers/SettingController.php b/app/Http/Controllers/SettingController.php deleted file mode 100644 index 22dce38..0000000 --- a/app/Http/Controllers/SettingController.php +++ /dev/null @@ -1,63 +0,0 @@ -middleware('auth'); - } - - public function index() { - $settings = getSettings(); - return kview('settings.general', [ - 'form_action' => route('admin.settings.update'), - 'edit' => 1, - 'settings' => $settings, - ]); - } - public function edit_profile() { - $user = Auth::user(); - $roles = Role::get(); - return kview('users.manage', [ - 'form_action' => route('admin.users.update'), - 'edit' => 1, - 'data' => $user, - 'roles' => $roles, - ]); - } - - public function update(Request $request) { - if (isset($request->SITE_NAME)) { - $this->updateSetting('SITE_NAME', $request->SITE_NAME); - } - if (isset($request->site_url)) { - $this->updateSetting('site_url', $request->site_url); - } - if (isset($request->tagline)) { - $this->updateSetting('tagline', $request->tagline); - } - if (isset($request->theme)) { - $this->updateSetting('theme', $request->theme); - } - return redirect()->back()->with('success', 'Settings has been updated'); - } - public function updateSetting($key, $value) { - $where = [ - 'key' => $key, - ]; - $update_array = [ - 'value' => $value, - ]; - Table::updateOrCreate($where, $update_array); - } -} diff --git a/app/Http/Controllers/TestController.php b/app/Http/Controllers/TestController.php index 7bdc515..7e8770d 100644 --- a/app/Http/Controllers/TestController.php +++ b/app/Http/Controllers/TestController.php @@ -4,12 +4,11 @@ use Illuminate\Http\Request; -class TestController extends Controller -{ - public function someFunction(){ - return 1; - } - public function test(){ - return $this->someFunction(); - } +class TestController extends Controller { + public function someFunction() { + return 1; + } + public function test() { + return $this->someFunction(); + } } diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index 47d1c51..cae8592 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -15,211 +15,214 @@ use Auth; use Illuminate\Support\Facades\Hash; -class UserController extends Controller -{ - protected $handle_name = "user"; - protected $handle_name_plural = "users"; - - public function index() - { - $all_count = Table::count(); - $trashed_count = Table::onlyTrashed()->count(); - return kview($this->handle_name_plural.'.index', [ - 'ajax_route' => route('admin.'.$this->handle_name_plural.'.ajax'), - 'delete_route'=> route('admin.'.$this->handle_name_plural.'.delete'), - 'create_route' => route('admin.'.$this->handle_name_plural.'.create'), - 'table_status'=> 'all', //all , trashed - 'all_count'=>$all_count, - 'trashed_count'=>$trashed_count, - ]); +class UserController extends Controller { + protected $handle_name = "user"; + protected $handle_name_plural = "users"; - } - public function create() - { - $roles = Role::get(); - return kview($this->handle_name_plural.'.manage', [ - 'form_action' => route('admin.'.$this->handle_name_plural.'.store'), - 'edit' => 0, - 'roles'=>$roles, - ]); - } - public function edit(Request $request) - { - $roles = Role::get(); - return kview($this->handle_name_plural.'.manage', [ - 'form_action' => route('admin.'.$this->handle_name_plural.'.update'), - 'edit' => 1, - 'data' => Table::where('id', '=', $request->id)->first(), - 'roles'=>$roles, - ]); - } - public function store(AddRequest $request) - { - try { - if(isset($request->two_factor_enable) && $request->two_factor_enable=="on"){ - $two_factor_enable = 1; - }else{ - $two_factor_enable = 0; - } + public function index() { + $all_count = Table::count(); + $trashed_count = Table::onlyTrashed()->count(); + return kview($this->handle_name_plural . '.index', [ + 'ajax_route' => route('admin.' . $this->handle_name_plural . '.ajax'), + 'delete_route' => route('admin.' . $this->handle_name_plural . '.delete'), + 'create_route' => route('admin.' . $this->handle_name_plural . '.create'), + 'table_status' => 'all', //all , trashed + 'all_count' => $all_count, + 'module_names' => [ + 'singular' => $this->handle_name, + 'plural' => $this->handle_name_plural, + ], + 'trashed_count' => $trashed_count, + ]); + } + public function create() { + $roles = Role::get(); + return kview($this->handle_name_plural . '.manage', [ + 'form_action' => route('admin.' . $this->handle_name_plural . '.store'), + 'edit' => 0, + 'module_names' => [ + 'singular' => $this->handle_name, + 'plural' => $this->handle_name_plural, + ], + 'roles' => $roles, + ]); + } + public function edit(Request $request) { + $roles = Role::get(); + return kview($this->handle_name_plural . '.manage', [ + 'form_action' => route('admin.' . $this->handle_name_plural . '.update'), + 'edit' => 1, + 'data' => Table::where('id', '=', $request->id)->first(), + 'module_names' => [ + 'singular' => $this->handle_name, + 'plural' => $this->handle_name_plural, + ], + 'roles' => $roles, + ]); + } + public function store(AddRequest $request) { + try { + if (isset($request->two_factor_enable) && $request->two_factor_enable == "on") { + $two_factor_enable = 1; + } else { + $two_factor_enable = 0; + } - $table = Table::create([ - 'name'=>$request->name, - 'email'=>$request->email, - 'password'=>bcrypt($request->password), - 'two_factor_enable'=>$two_factor_enable - ]); + $table = Table::create([ + 'name' => $request->name, + 'email' => $request->email, + 'password' => bcrypt($request->password), + 'two_factor_enable' => $two_factor_enable + ]); - if(isset($request->role)){ - $table->syncRoles($request->role); - } - - return redirect()->to(route('admin.'.$this->handle_name_plural.'.index'))->with('success', 'New '.ucfirst($this->handle_name).' has been added.'); - } catch (Exception $e) { - return $e->getMessage(); - return redirect()->back()->with('error', $e->getMessage()); - } + if (isset($request->role)) { + $table->syncRoles($request->role); + } + + return redirect()->to(route('admin.' . $this->handle_name_plural . '.index'))->with('success', 'New ' . ucfirst($this->handle_name) . ' has been added.'); + } catch (Exception $e) { + return $e->getMessage(); + return redirect()->back()->with('error', $e->getMessage()); } - public function update(UpdateRequest $request) - { - try { - if(isset($request->two_factor_enable) && $request->two_factor_enable=="on"){ - $two_factor_enable = 1; - }else{ - $two_factor_enable = 0; - } - $update_data = [ - 'name'=>$request->name, - 'email'=>$request->email, - 'two_factor_enable'=>$two_factor_enable, - ]; + } + public function update(UpdateRequest $request) { + try { + if (isset($request->two_factor_enable) && $request->two_factor_enable == "on") { + $two_factor_enable = 1; + } else { + $two_factor_enable = 0; + } + $update_data = [ + 'name' => $request->name, + 'email' => $request->email, + 'two_factor_enable' => $two_factor_enable, + ]; - if(isset($request->old_password)){ - // $password= Hash::make($request->password); - $userObj = Table::where([ - 'id'=>$request->id, - ])->first(); - if (Hash::check($request->old_password, $userObj->password)) { - $update_data['password'] = bcrypt($request->password); - }else{ - return redirect()->back()->with('error', "Old password is incorrect."); - } - } - $where = [ - 'id'=>$request->id - ]; + if (isset($request->old_password)) { + // $password= Hash::make($request->password); + $userObj = Table::where([ + 'id' => $request->id, + ])->first(); + if (Hash::check($request->old_password, $userObj->password)) { + $update_data['password'] = bcrypt($request->password); + } else { + return redirect()->back()->with('error', "Old password is incorrect."); + } + } + $where = [ + 'id' => $request->id + ]; - $user = Table::updateOrCreate($where,$update_data); - if(isset($request->role)){ - $user->syncRoles($request->role); - } + $user = Table::updateOrCreate($where, $update_data); + if (isset($request->role)) { + $user->syncRoles($request->role); + } - return redirect()->back()->with('success', ucfirst($this->handle_name).' has been updated'); - } catch (Exception $e) { - return redirect()->back()->with('error', $e->getMessage()); - } + return redirect()->back()->with('success', ucfirst($this->handle_name) . ' has been updated'); + } catch (Exception $e) { + return redirect()->back()->with('error', $e->getMessage()); + } + } + public function ajax(Request $request) { + $edit_route = route('admin.' . $this->handle_name_plural . '.edit'); + $current_page = $request->page_number; + if (isset($request->limit)) { + $limit = $request->limit; + } else { + $limit = 10; + } + $offset = (($current_page - 1) * $limit); + $modalObject = new Table(); + if (isset($request->string)) { + $string = $request->string; + $modalObject = $modalObject->where('name', 'like', "%" . $request->string . "%"); + // $modalObject = $modalObject->orWhere('name','like',"%".$request->string."%"); } - public function ajax(Request $request) - { - $edit_route = route('admin.'.$this->handle_name_plural.'.edit'); - $current_page = $request->page_number; - if (isset($request->limit)) { - $limit = $request->limit; - } else { - $limit = 10; - } - $offset = (($current_page - 1) * $limit); - $modalObject = new Table(); - if (isset($request->string)) { - $string = $request->string; - $modalObject = $modalObject->where('name', 'like', "%" . $request->string . "%"); - // $modalObject = $modalObject->orWhere('name','like',"%".$request->string."%"); - } - - $all_trashed = $request->all_trashed; - if($all_trashed=="trashed"){ - $modalObject = $modalObject->onlyTrashed(); - } - $total_records = $modalObject->count(); - $modalObject = $modalObject->offset($offset); - $modalObject = $modalObject->take($limit); - $data = $modalObject->get(); - - if (isset($request->page_number) && $request->page_number != 1) { - $page_number = $request->page_number + $limit - 1; - } else { - $page_number = 1; - } - $pagination = array( - "offset" => $offset, - "total_records" => $total_records, - "item_per_page" => $limit, - "total_pages" => ceil($total_records / $limit), - "current_page" => $current_page, - ); + $all_trashed = $request->all_trashed; + if ($all_trashed == "trashed") { + $modalObject = $modalObject->onlyTrashed(); + } + + $total_records = $modalObject->count(); + $modalObject = $modalObject->offset($offset); + $modalObject = $modalObject->take($limit); + $data = $modalObject->get(); + + if (isset($request->page_number) && $request->page_number != 1) { + $page_number = $request->page_number + $limit - 1; + } else { + $page_number = 1; + } + $pagination = array( + "offset" => $offset, + "total_records" => $total_records, + "item_per_page" => $limit, + "total_pages" => ceil($total_records / $limit), + "current_page" => $current_page, + ); - return kview($this->handle_name_plural.'.ajax', compact('edit_route', 'data', 'page_number', 'limit', 'offset', 'pagination')); + return kview($this->handle_name_plural . '.ajax', compact('edit_route', 'data', 'page_number', 'limit', 'offset', 'pagination')); + } + public function delete(Request $request) { + if (isset($request->action)) { + $action = $request->action; + $is_bulk = $request->is_bulk; + $data_id = $request->data_id; } - public function delete(Request $request) - { - if(isset($request->action)){ - $action = $request->action; - $is_bulk = $request->is_bulk; - $data_id = $request->data_id; + switch ($action) { + case 'restore': + try { + if ($is_bulk == 1) { + $data_id = explode(",", $data_id); + $table = Table::onlyTrashed()->whereIn('id', $data_id); + $table->restore(); + return 1; + } else { + $table = Table::onlyTrashed()->find($data_id); + $table->restore(); + return 1; + } + } catch (Exception $e) { + return redirect()->back()->with('error', $e->getMessage()); } - switch ($action){ - case 'restore': - try{ - if($is_bulk==1){ - $data_id = explode(",",$data_id); - $table = Table::onlyTrashed()->whereIn('id',$data_id); - $table->restore(); - return 1; - }else{ - $table = Table::onlyTrashed()->find($data_id); - $table->restore(); - return 1; - } - } catch (Exception $e) { - return redirect()->back()->with('error', $e->getMessage()); - } - break; - case 'trash' : - try{ - if($is_bulk==1){ - $data_id = explode(",",$data_id); - $table = Table::whereIn('id',$data_id); - $table->delete(); - return 1; - }else{ - $table = Table::find($data_id); - $table->delete(); - return 1; - } - } catch (Exception $e) { - return redirect()->back()->with('error', $e->getMessage()); - } - break; - case 'delete' : - try{ - if($is_bulk==1){ - $data_id = explode(",",$data_id); - $table = Table::withTrashed()->whereIn('id',$data_id)->get(); - foreach($table as $tbl){ - $tbl->forceDelete(); - } - return 1; - }else{ - $table = Table::withTrashed()->find($data_id); - $data = $table->forceDelete(); - return 1; - } - } catch (Exception $e) { - return redirect()->back()->with('error', $e->getMessage()); - } - break; - default : - return 0; + break; + case 'trash': + try { + if ($is_bulk == 1) { + $data_id = explode(",", $data_id); + $table = Table::whereIn('id', $data_id); + $table->delete(); + return 1; + } else { + $table = Table::find($data_id); + $table->delete(); + return 1; + } + } catch (Exception $e) { + return redirect()->back()->with('error', $e->getMessage()); + } + break; + case 'delete': + try { + if ($is_bulk == 1) { + $data_id = explode(",", $data_id); + $table = Table::withTrashed()->whereIn('id', $data_id)->get(); + foreach ($table as $tbl) { + $tbl->forceDelete(); + } + return 1; + } else { + $table = Table::withTrashed()->find($data_id); + $data = $table->forceDelete(); + return 1; + } + } catch (Exception $e) { + return redirect()->back()->with('error', $e->getMessage()); } + break; + default: + return 0; } + } } diff --git a/resources/views/backend/home.blade.php b/resources/views/backend/home.blade.php index 2c9130c..f4f45fc 100644 --- a/resources/views/backend/home.blade.php +++ b/resources/views/backend/home.blade.php @@ -2,6 +2,7 @@ @section('content')
+ @include($theme_name.'.layouts.partial.breadcrumb')
@if (session('status'))