/** * Run the database seeds. * * @return void */ public function run() { DB::table('struct_trls')->delete(); StructTrl::create(['lng_id' => 1, 'struct_id' => 1, 'trl' => 'Home']); StructTrl::create(['lng_id' => 2, 'struct_id' => 1, 'trl' => 'Главная']); StructTrl::create(['lng_id' => 1, 'struct_id' => 2, 'trl' => 'Slides']); StructTrl::create(['lng_id' => 2, 'struct_id' => 2, 'trl' => 'Слайдер']); StructTrl::create(['lng_id' => 1, 'struct_id' => 3, 'trl' => 'Products']); StructTrl::create(['lng_id' => 2, 'struct_id' => 3, 'trl' => 'Продукты']); StructTrl::create(['lng_id' => 1, 'struct_id' => 4, 'trl' => 'Uniq detail']); StructTrl::create(['lng_id' => 2, 'struct_id' => 4, 'trl' => 'Уникальные фишки']); StructTrl::create(['lng_id' => 1, 'struct_id' => 5, 'trl' => 'History']); StructTrl::create(['lng_id' => 2, 'struct_id' => 5, 'trl' => 'История']); StructTrl::create(['lng_id' => 1, 'struct_id' => 6, 'trl' => 'Home']); StructTrl::create(['lng_id' => 2, 'struct_id' => 6, 'trl' => 'Отзывы']); StructTrl::create(['lng_id' => 1, 'struct_id' => 7, 'trl' => 'About me']); StructTrl::create(['lng_id' => 2, 'struct_id' => 7, 'trl' => 'Обо мне']); StructTrl::create(['lng_id' => 1, 'struct_id' => 8, 'trl' => 'Contacts']); StructTrl::create(['lng_id' => 2, 'struct_id' => 8, 'trl' => 'Контакты']); }
public function patchUpdateStruct(StructEditRequest $request, $id) { $struct = Structure::findOrFail((int) $id); //updating $inputArr = $request->input(); if (!isset($inputArr['active'])) { $inputArr['active'] = false; } $struct->update($inputArr); //update trls foreach ($request->input('trl') as $lng_id => $value) { $translation = StructTrl::oneTrl((int) $lng_id, (int) $id)->get()->shift(); if (!empty($translation)) { $translation->trl = $value; $translation->save(); } else { continue; } } return redirect()->action('Admin\\MainController@getEditStruct', ['id' => $id])->with(['message' => 'Block has been updated']); }