From 14681d2d2daf27aaaad4618adcda3911e1b99fc3 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: Mon, 22 Apr 2024 16:07:15 +0700 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B0=D0=B1=D0=BE=D1=82=D0=BE=D0=B4=D0=B0=D1?= =?UTF-8?q?=82=D0=B5=D0=BB=D0=B8=20=D0=BA=D0=B0=D0=B1=D0=B8=D0=BD=D0=B5=D1=82?= =?UTF-8?q?=20-=20=D1=80=D0=B5=D0=B4=D0=B0=D0=BA=D1=82=D0=B8=D1=80=D0=BE=D0=B2?= =?UTF-8?q?=D0=B0=D0=BD=D0=B8=D0=B5=20=D1=84=D0=BB=D0=BE=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/EmployerController.php | 20 ++++ app/Http/Requests/FlotRequest.php | 8 +- resources/views/employers/edit-flot.blade.php | 147 +++++++++++++++++++++++++ resources/views/employers/fly-flot.blade.php | 9 +- routes/web.php | 2 + 5 files changed, 181 insertions(+), 5 deletions(-) create mode 100644 resources/views/employers/edit-flot.blade.php diff --git a/app/Http/Controllers/EmployerController.php b/app/Http/Controllers/EmployerController.php index 6553f5a..d86356c 100644 --- a/app/Http/Controllers/EmployerController.php +++ b/app/Http/Controllers/EmployerController.php @@ -131,6 +131,26 @@ class EmployerController extends Controller return redirect()->route('employer.slider_flot')->with('success', 'Новый корабль был добавлен'); } + public function edit_flot(Flot $Flot, Employer $Employer) { + return view('employers.edit-flot', compact('Flot', 'Employer')); + } + + public function update_flot(FlotRequest $request, Flot $Flot) { + $params = $request->all(); + + if ($request->has('image')) { + if (!empty($flot->image)) { + Storage::delete($flot->image); + } + $params['image'] = $request->file('image')->store("flot", 'public'); + } else { + if (!empty($flot->image)) $params['image'] = $flot->image; + } + + $Flot->update($params); + return redirect()->route('employer.slider_flot')->with('success', 'Новый корабль был добавлен'); + } + public function delete_flot(Flot $Flot) { $data_flots = Flot::query()->where('employer_id', $Flot->employer_id)->get(); diff --git a/app/Http/Requests/FlotRequest.php b/app/Http/Requests/FlotRequest.php index 8ba08ec..c9596f5 100644 --- a/app/Http/Requests/FlotRequest.php +++ b/app/Http/Requests/FlotRequest.php @@ -26,10 +26,10 @@ class FlotRequest extends FormRequest return [ 'name' => 'required|min:3|max:255', 'text' => 'required|min:5', - 'image' => [ - 'mimes:jpeg,jpg,png', - 'max:20000' - ], + //'image' => [ + // 'mimes:jpeg,jpg,png', + // 'max:20000' + //], 'region' => 'required|min:3|max:255', 'power' => 'required|min:3|max:255' ]; diff --git a/resources/views/employers/edit-flot.blade.php b/resources/views/employers/edit-flot.blade.php new file mode 100644 index 0000000..8567d7d --- /dev/null +++ b/resources/views/employers/edit-flot.blade.php @@ -0,0 +1,147 @@ +@extends('layout.frontend', ['title' => 'Редактирование флота - РекаМоре']) + +@section('scripts') + + +@endsection +@section('content') +
+
+ +
+
+
+ @include('employers.emblema') +
+ + @include('employers.menu', ['item' => 12]) + +
+
+ @include('messages_error') + +
+
+

Редактирование флота

+
+ +
+ @csrf + + +
+
+ +
+ + @error('name') + + {{ $message }} + + @enderror +
+
+ + + +
+ +
+ + @error('DWT') + + {{ $message }} + + @enderror +
+
+
+ +
+ + @error('POWER_GD') + + {{ $message }} + + @enderror +
+
+
+ +
+ + @error('IMO') + + {{ $message }} + + @enderror +
+
+ +
+
+
+
+
+
+ +
+ + +@endsection diff --git a/resources/views/employers/fly-flot.blade.php b/resources/views/employers/fly-flot.blade.php index 0ba4b3d..53227de 100644 --- a/resources/views/employers/fly-flot.blade.php +++ b/resources/views/employers/fly-flot.blade.php @@ -133,7 +133,7 @@ @enderror - + @@ -143,11 +143,18 @@ @if ($Employer[0]->flots->count()) @foreach ($Employer[0]->flots as $it)
+
+ + + + + +
@if (!empty($it->image)) {{ $it->name }} @else diff --git a/routes/web.php b/routes/web.php index 3f172e4..e4f5fe1 100644 --- a/routes/web.php +++ b/routes/web.php @@ -557,6 +557,8 @@ Route::group([ Route::post('cabinet/{Employer}', [EmployerController::class, 'cabinet_save'])->name('cabinet_save'); Route::post('flot_add_ajax', [EmployerController::class, 'save_add_flot'])->name('save_add_flot'); Route::get('flot_delete_ajax/{Flot}', [EmployerController::class, 'delete_flot'])->name('delete_flot'); + Route::get('cabinet/flot_edit/{Flot}/{Employer}', [EmployerController::class, 'edit_flot'])->name('edit_flot'); + Route::post('cabinet/flot_edit/{Flot}', [EmployerController::class, 'update_flot'])->name('update_flot_save'); Route::get('cabinet/flot', [EmployerController::class, 'slider_flot'])->name('slider_flot'); // 2 страница - Добавление вакансий -- 1.7.10.4