function newSubcategory(Request $request)
 {
     $imageName = str_random(40) . '**' . $request->file('subcategoryImage')->getClientOriginalName();
     $subcategory = new Subcategory(['categories_id' => $request->input('category'), 'name' => $request->input('subcategory')]);
     $request->file('subcategoryImage')->move(base_path() . '/public/uploads/categories/', $imageName);
     $subcategory->url_image = $imageName;
     $subcategory->save();
     $categories = Category::all();
     return view('back.categories', compact('categories'));
 }
 private function createCategory()
 {
     Category::create(['id' => '1', 'name' => 'FERTILIZANTES']);
     Category::create(['id' => '2', 'name' => 'INSUMOS']);
     Category::create(['id' => '3', 'name' => 'MAQUINARIA Y EQUIPOS']);
     Category::create(['id' => '4', 'name' => 'LOGISTICA Y TRANSPORTE']);
     Category::create(['id' => '5', 'name' => 'SERVICIOS ESPECIALES']);
     Category::create(['id' => '6', 'name' => 'INSUMOS PECUARIOS']);
     Category::create(['id' => '7', 'name' => 'TECNOLOGIA AGRICOLA']);
 }
 function editProduct($id)
 {
     $brands = Brand::all();
     $farms = FarmCategory::with('farms')->get();
     $categories = Category::all();
     $user = auth()->user();
     if ($user->role_id == 1) {
         $productEdit = Product::find($id);
         return view('back.productAdminEdit', compact('productEdit', 'offerEdit', 'categories', 'farms', 'brands'));
     } else {
         $productEdit = ProductProvider::find($id);
         $offer = $productEdit->offer()->first();
         return view('back.productProviderEdit', compact('productEdit', 'offer', 'categories', 'farms', 'brands'));
     }
 }
Example #4
0
 public function getCategory()
 {
     return Category::with('subcategories')->get();
 }
 function categoriesSubcategories()
 {
     return Category::all();
 }