Example #1
0
 public function getAll()
 {
     // Get All Languages
     $languages = Language::get();
     // Passing data to response service
     return $this->responseService->returnMessage($languages, 'No Languages were Found.');
 }
 public function guardarTraduccion($request, $id)
 {
     $producto = Product::findOrFail($id);
     $producto->name = $request->input('name');
     $producto->description = $request->input('description');
     $producto->save();
     $languages = Language::get();
     foreach ($languages as $lang) {
         $nameLang = $request->input('name' . $lang->id);
         $descLang = $request->input('description' . $lang->id);
         if (trim($nameLang) != "" && trim($descLang) != "") {
             $languages_products = LanguageProduct::where('id_language', $lang->id)->where('id_product', $producto->id)->first();
             if (!isset($languages_products->id)) {
                 $languages_products = new LanguageProduct();
             }
             $languages_products->id_language = $lang->id;
             $languages_products->id_product = $producto->id;
             $languages_products->name = $nameLang;
             $languages_products->description = $descLang;
             $languages_products->save();
         } else {
             $languages_products = LanguageProduct::where('id_language', $lang->id)->where('id_product', $producto->id)->first();
             if (isset($languages_products->id)) {
                 $languages_products->delete();
             }
         }
     }
 }
 public function guardarTraduccion($request, $id)
 {
     $categoria = Category::findOrFail($id);
     $categoria->name = $request->input('name');
     $categoria->save();
     $languages = Language::get();
     foreach ($languages as $lang) {
         $nameLang = $request->input('name' . $lang->id);
         if (trim($nameLang) != "") {
             $languages_categories = LanguageCategory::where('id_language', $lang->id)->where('id_category', $categoria->id)->first();
             if (!isset($languages_categories->id)) {
                 $languages_categories = new LanguageCategory();
             }
             $languages_categories->id_language = $lang->id;
             $languages_categories->id_category = $categoria->id;
             $languages_categories->name = $nameLang;
             $languages_categories->save();
         } else {
             $languages_categories = LanguageCategory::where('id_language', $lang->id)->where('id_category', $categoria->id)->first();
             if (isset($languages_categories->id)) {
                 $languages_categories->delete();
             }
         }
     }
 }