From 90302d36633b80a73985b19c1a677ce5552f2795 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D0=B4=D1=80=D0=B5=D0=B9=20=20=D0=9B=D0=B0=D1=80?= =?UTF-8?q?=D0=B8=D0=BE=D0=BD=D0=BE=D0=B2?= Date: Thu, 14 Sep 2023 21:33:25 +0700 Subject: [PATCH] =?UTF-8?q?=D0=91=D0=BB=D0=BE=D0=BA=D0=B8=20=D0=BC=D0=B5=D0=BD?= =?UTF-8?q?=D1=8E=20=D0=B4=D0=BB=D1=8F=20=D1=84=D1=83=D1=82=D0=B5=D1=80=D0=B0?= =?UTF-8?q?=20=D0=B8=20=D1=88=D0=B0=D0=BF=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Admin/CompanyController.php | 47 ++++++++++++++- app/Models/header_footer.php | 9 +++ resources/views/admin/editbloks/add.blade.php | 7 +++ resources/views/admin/editbloks/edit.blade.php | 7 +++ resources/views/admin/editbloks/form.blade.php | 61 ++++++++++++++++++++ resources/views/admin/editbloks/index.blade.php | 47 +++++++++++---- .../views/admin/editbloks/index_ajax.blade.php | 10 ++-- .../views/admin/editbloks/parent_id.blade.php | 10 ++++ routes/web.php | 8 +++ 9 files changed, 188 insertions(+), 18 deletions(-) create mode 100644 resources/views/admin/editbloks/add.blade.php create mode 100644 resources/views/admin/editbloks/edit.blade.php create mode 100644 resources/views/admin/editbloks/form.blade.php create mode 100644 resources/views/admin/editbloks/parent_id.blade.php diff --git a/app/Http/Controllers/Admin/CompanyController.php b/app/Http/Controllers/Admin/CompanyController.php index 1d139b7..6663b24 100644 --- a/app/Http/Controllers/Admin/CompanyController.php +++ b/app/Http/Controllers/Admin/CompanyController.php @@ -43,19 +43,62 @@ class CompanyController extends Controller } } + //////////////////////////////////////////////////////////////////////////////// // кабинет - редактор шапки-футера сайта public function editblocks(Request $request) { if ($request->ajax()) { $header_footer = header_footer::where('header', $request->header)->OrderBy('sort')->OrderBy('name')->paginate(15); $list_menu = header_footer::where('header', $request->header)->OrderBy('name')->get(); - return view('admin.editbloks.index_ajax', compact('header_footer')); + return view('admin.editbloks.index_ajax', compact('header_footer', 'list_menu')); } else { $header_footer = header_footer::where('header', '1')->OrderBy('sort')->OrderBy('name')->paginate(15); $list_menu = header_footer::where('header', '1')->OrderBy('name')->get(); - return view('admin.editbloks.index', compact('header_footer')); + return view('admin.editbloks.index', compact('header_footer', 'list_menu')); } } + public function editblock_add() { + $items = header_footer::query()->OrderBy('name')->get(); + return view('admin.editbloks.add', compact('items')); + } + + public function editblock_store(Request $request) { + header_footer::create($request->all()); + return redirect()->route('admin.edit-blocks'); + } + + public function editblock_ajax(Request $request) { + if ($request->ajax()) { + $hf = header_footer::find($request->id); + $filter = $request->header; + unset($request->id); + unset($request->header); + $hf->update($request->all()); + + $header_footer = header_footer::where('header', $filter)->OrderBy('sort')->OrderBy('name')->paginate(15); + $list_menu = header_footer::where('header', $filter)->OrderBy('name')->get(); + return view('admin.editbloks.index_ajax', compact('header_footer', 'list_menu')); + } else { + return "Ошибка!"; + } + } + + public function editblock_edit(header_footer $block) { + $items = header_footer::query()->OrderBy('name')->get(); + return view('admin.editbloks.edit', compact('block', 'items')); + } + + public function editblock_update(Request $request, header_footer $block) { + $block->update($request->all()); + return redirect()->route('admin.edit-blocks'); + } + + public function editblock_destroy(header_footer $block) { + $block->delete(); + return redirect()->route('admin.edit-blocks'); + } + ///////////////////////////////////////////////////////// + // кабинет - редактор работодатели на главной public function employers_main(Request $request) { if ($request->ajax()) { diff --git a/app/Models/header_footer.php b/app/Models/header_footer.php index b9e7a28..2d3bc58 100644 --- a/app/Models/header_footer.php +++ b/app/Models/header_footer.php @@ -8,4 +8,13 @@ use Illuminate\Database\Eloquent\Model; class header_footer extends Model { use HasFactory; + + protected $fillable = [ + 'name', + 'link', + 'code_id', + 'category', + 'header', + 'sort' + ]; } diff --git a/resources/views/admin/editbloks/add.blade.php b/resources/views/admin/editbloks/add.blade.php new file mode 100644 index 0000000..5c7983d --- /dev/null +++ b/resources/views/admin/editbloks/add.blade.php @@ -0,0 +1,7 @@ +@extends('layout.admin', ['title' => 'Админка - Добавление элемента шапки-футера']) + +@section('content') +
+ @include('admin.editbloks.form') +
+@endsection diff --git a/resources/views/admin/editbloks/edit.blade.php b/resources/views/admin/editbloks/edit.blade.php new file mode 100644 index 0000000..a29ba31 --- /dev/null +++ b/resources/views/admin/editbloks/edit.blade.php @@ -0,0 +1,7 @@ +@extends('layout.admin', ['title' => 'Админка - Редактирование элемента шапки-футера']) + +@section('content') +
+ @include('admin.editbloks.form') +
+@endsection diff --git a/resources/views/admin/editbloks/form.blade.php b/resources/views/admin/editbloks/form.blade.php new file mode 100644 index 0000000..2565c66 --- /dev/null +++ b/resources/views/admin/editbloks/form.blade.php @@ -0,0 +1,61 @@ +@csrf +@isset($block) + @method('PUT') +@endisset + +
+
+ +
+ +
+ +
+ +
+
+ +
+
+
diff --git a/resources/views/admin/editbloks/index.blade.php b/resources/views/admin/editbloks/index.blade.php index b1f6ee7..7d67db1 100644 --- a/resources/views/admin/editbloks/index.blade.php +++ b/resources/views/admin/editbloks/index.blade.php @@ -3,16 +3,45 @@ @section('script')