From 636d814c5300f2fd514fcd45315c913ef282ff09 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: Wed, 15 Nov 2023 16:17:51 +0700 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B5=D0=B4=D0=B0=D0=BA=D1=82=D0=BE=D1=80=20?= =?UTF-8?q?=D1=82=D0=B0=D0=B1=D0=BE=D0=B2=20=D0=BE=D0=B1=D1=80=D0=B0=D0=B7=D0?= =?UTF-8?q?=BE=D0=B2=D0=B0=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Admin/EducationController.php | 17 +++++++++++++++++ resources/views/admin/education/form.blade.php | 17 ++++++++++++++--- routes/web.php | 1 + 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/Admin/EducationController.php b/app/Http/Controllers/Admin/EducationController.php index b0d73d3..1b72ae3 100644 --- a/app/Http/Controllers/Admin/EducationController.php +++ b/app/Http/Controllers/Admin/EducationController.php @@ -8,6 +8,7 @@ use App\Http\Requests\ProgramEducationRequest; use App\Models\Education; use App\Models\ProgramEducation; use Illuminate\Http\Request; +use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Storage; class EducationController extends Controller @@ -108,6 +109,22 @@ class EducationController extends Controller return redirect()->route('admin.education.index'); } + public function rename_program(Request $request) { + if ($request->ajax()) { + $oldnamelevel = $request->oldname; + $newnamelevel = $request->newname; + $id_education = $request->id_education; + + $result = DB::table('program_education') + ->where('education_id', '=', $id_education) + ->where('level', '=', $oldnamelevel) + ->update(['level' => $newnamelevel]); + + return $result; + } else return ""; + + } + public function add_program(Request $request) { $id_education = $request->id; $level = $request->level; diff --git a/resources/views/admin/education/form.blade.php b/resources/views/admin/education/form.blade.php index f4f4ba8..10d57da 100644 --- a/resources/views/admin/education/form.blade.php +++ b/resources/views/admin/education/form.blade.php @@ -246,10 +246,21 @@ e.preventDefault(); } - /*if (tabsInput.dataset.edit) { + if (tabsInput.dataset.edit) { tabsBtns.forEach(btn => { if (tabsInput.dataset.edit === btn.dataset.id) { + console.log('oldname: '+btn.textContent+' newname: '+tabsInputValue+' id_education: '+id?>+''); + $.ajax({ + url: '{{ route('admin.rename-program-education') }}', + method: 'get', /* Метод запроса (post или get) */ + dataType: 'html', /* Тип данных в ответе (xml, json, script, html). */ + data: {oldname: btn.textContent, newname:tabsInputValue, id_education: id?>}, /* Данные передаваемые в массиве */ + success: function(data){ /* функция которая будет выполнена после успешного запроса. */ + console.log(data); /* В переменной data содержится ответ от index.php. */ + } + }); + btn.textContent = tabsInputValue; btn.dataset.btn = tabsInputValue; } @@ -261,7 +272,7 @@ if (!tabsBtns.length) { tabsButtons.innerHTML += getTabsBtnTemplate(tabsInputValue, id); - tabsContent.innerHTML += getTabsItemTemplate(id); + //tabsContent.innerHTML += getTabsItemTemplate(id); } if (tabsBtns.length && tabsBtns.length < qty) { @@ -280,7 +291,7 @@ tabsContent.innerHTML += getTabsItemTemplate(id, 'hidden'); } } - }*/ + } //tabsInput.value = ''; addDisabledBtnStatus(tabsSubmitBtn); diff --git a/routes/web.php b/routes/web.php index f3596f9..6d1a073 100644 --- a/routes/web.php +++ b/routes/web.php @@ -226,6 +226,7 @@ Route::group([ // CRUD-операции над справочником Образование Route::resource('education', EducationController::class, ['except' => ['show']]); + Route::get('rename-program-education', [EducationController::class, 'rename_program'])->name('rename-program-education'); Route::get('program-education', [EducationController::class, 'add_program'])->name('add-program-education'); Route::post('program-education', [EducationController::class, 'store_program'])->name('store-program-education'); -- 1.7.10.4