app/Http/Controllers/CategoryController.php
//----insert parent and child category into 'Categories' table using the Category model
insert parent and child category into 'Categories' table using the Category model
insert parent and child category into ' Categories ' table using the Category model
public function categorie_Add(CategorieRequest $request){
        if($request->id != 'null'){
           $id =  $request->id;
        }else{
            $id = Null;
        }
        $translation_table = TranslationLang::all();
        foreach ($translation_table as $language){
            $lang = $language->folder;
            $file = $lang.'.json';
            $destinationPath=storage_path('..\resources\lang\\');
            $path_ru = storage_path('..\resources\lang\\'.$file);
            $lang = json_decode(file_get_contents($path_ru), true);
            $lang[$request->categori_name] = $request->categori_name;
            File::put($destinationPath.$file, json_encode($lang));
        }
        Category::create([
            'name' => $request->categori_name,
            'category_id'=> $id,
            'role' => $request->role,
        ]);
        return redirect()->back();
    }
public function categorie_Add ( CategorieRequest $ request ) { if ( $ request -> id != 'null' ) { $ id = $ request -> id ; } else { $ id = Null ; } $ translation_table = TranslationLang :: all ( ) ; foreach ( $ translation_table as $ language ) { $ lang = $ language -> folder ; $ file = $ lang . '.json' ; $ destinationPath = storage_path ( '..\resources\lang\\' ) ; $ path_ru = storage_path ( '..\resources\lang\\' . $ file ) ; $ lang = json_decode ( file_get_contents ( $ path_ru ) , true ) ; $ lang [ $ request -> categori_name ] = $ request -> categori_name ; File :: put ( $ destinationPath . $ file , json_encode ( $ lang ) ) ; } Category :: create ( [ 'name' => $ request -> categori_name , 'category_id' => $ id , 'role' => $ request -> role , ] ) ; return redirect ( ) -> back ( ) ; }
insert parent and child category into 'Categories' table using the Category model
insert parent and child category into ' Categories ' table using the Category model
//        $file = 'title.json'; //        $destinationPath = storage_path('..\resources\lang\\'); //        $path = storage_path('..\resources\lang\\'.$file); //        $lang = json_decode(file_get_contents($path), true); //        $lang[$request->categori_name] = $request->categori_name; //        File::put($destinationPath.$file, json_encode($lang));