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') +
+@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') + +@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 + +