Example #1
0
 public static function searchFabric($name)
 {
     return Fabric::where("name", "like", "%" . $name . "%")->orderBy("created_at", "desc")->get();
 }
Example #2
0
 public function updateImages($product, $arrayImages, $main_photo)
 {
     $i = 0;
     $returned_thumbs = [];
     $path = "";
     $cuenta = count($arrayImages);
     foreach ($arrayImages as $img) {
         $extenArray = explode(".", $img->getClientOriginalName());
         $extension = end($extenArray);
         $name = $i . date("Y-m-d-H-i-s") . "fotoId" . $product . "." . $extension;
         if ($i == $cuenta - 1 && $main_photo != "false") {
             // Upload Product Picture and URI
             $img->move("assets/img/fabric-images/", $name);
             $aux_product = Fabric::where('id', '=', $product)->get();
             $aux_product->image = $name;
             DB::table('fabrics')->where('id', $product)->update(array('image' => "assets/img/fabric-images/" . $name));
         } else {
             // Upload Thumbnails and URI's
             $img->move("assets/img/fabric-images/", $name);
             $img_aux = new Image();
             $img_aux->fabric_id = $product;
             $img_aux->path = "assets/img/fabric-images/" . $name;
             $img_aux->save();
             $returned_thumbs[$i] = $img_aux;
             $i++;
         }
         // end if
     }
     // end foreach
     return $returned_thumbs;
 }