/**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     //
     $order = Order::find($id);
     $order_detail = Order_detail::where('order_id', $id)->get();
     $product = Product::all();
     $color = Color::all();
     $size = Size::all();
     return view('backend.pages.order.detail', array('order' => $order, 'detail' => $order_detail, 'product' => $product, 'color' => $color, 'size' => $size));
 }
 private function getJSON()
 {
     $returnVar = array();
     $unicas = UniqueImage::get();
     foreach ($unicas as $value) {
         $unica[$value['id']]['route'] = $value['route'];
         $unica[$value['id']]['id'] = $value['id'];
     }
     $returnVar['unicas'] = json_encode($unica);
     //logica para el arreglo de las imagenes con sus variantes
     $images = Imagen::lists('route');
     for ($i = 0; $i < count($images); $i++) {
         $variantes = Imagen::where('route', '=', $images[$i])->first()->VariantImage;
         $images[$i] = ['ruta' => $images[$i], 'variantes' => $variantes];
     }
     $returnVar['variantes'] = json_encode($images);
     //logica para los colores
     $colors = Color::get();
     foreach ($colors as $color) {
         $colores[$color['id']] = $color['hex'];
     }
     $returnVar['colores'] = json_encode($colores);
     return $returnVar;
 }
Example #3
0
 public static function addColor($color)
 {
     $data = new Color();
     $data->name = $color;
     $data->save();
     return $data->id;
 }
 public function guardarDatos($request, $id)
 {
     $rules = ['name' => 'required', 'price' => 'required', 'id_category' => 'required'];
     $this->validate($request, $rules);
     if ($id != null) {
         $producto = Product::findOrFail($id);
     } else {
         $producto = new Product();
     }
     $producto->name = $request->input('name');
     $producto->description = $request->input('description');
     $producto->price = $request->input('price');
     $producto->id_category = $request->input('id_category');
     $producto->save();
     $colors = Color::orderBy('name', 'asc')->get();
     foreach ($colors as $col) {
         $checkColor = $request->input('color' . $col->id);
         if (isset($checkColor)) {
             $products_colors = ProductColor::where('id_color', $col->id)->where('id_product', $producto->id)->first();
             if (!isset($products_colors->id)) {
                 $products_colors = new ProductColor();
             }
             $products_colors->id_color = $col->id;
             $products_colors->id_product = $producto->id;
             $products_colors->save();
         } else {
             $products_colors = ProductColor::where('id_color', $col->id)->where('id_product', $producto->id)->first();
             if (isset($products_colors->id)) {
                 $products_colors->delete();
             }
         }
     }
 }
Example #5
0
 public static function search($type, $size, $maxPrice, $minPrice, $colors)
 {
     if ($colors == null) {
         $colors = Color::all();
         foreach ($colors as $key => $color) {
             $colors[$key] = $color->id;
         }
     }
     if ($colors != null && $type == null && $size == null) {
         return Product::where('price', '>=', $minPrice)->where('price', '<=', $maxPrice)->whereHas('colors', function ($query) use($colors) {
             $query->whereIn('id', $colors);
         })->get();
     }
     if ($type == null) {
         return Product::where('size', $size)->where('price', '>=', $minPrice)->where('price', '<=', $maxPrice)->whereHas('colors', function ($query) use($colors) {
             $query->whereIn('id', $colors);
         })->get();
     }
     if ($size == null) {
         return Product::where('FK_type', $type)->where('price', '>=', $minPrice)->where('price', '<=', $maxPrice)->whereHas('colors', function ($query) use($colors) {
             $query->whereIn('id', $colors);
         })->get();
     }
     return Product::where('size', $size)->where('FK_type', $type)->where('price', '>=', $minPrice)->where('price', '<=', $maxPrice)->whereHas('colors', function ($query) use($colors) {
         $query->whereIn('id', $colors);
     })->get();
 }
 public function update_product($domain, $productId, Request $request)
 {
     $product = Product::find($productId);
     foreach ($product->colors as $c) {
         $c->delete();
     }
     $colorStr = $request->colorStr;
     $colors = explode("#", $colorStr);
     foreach ($colors as $c) {
         $color = new Color();
         $color->product_id = $productId;
         $color->value = $c;
         $color->save();
     }
     return $this->respond(['message' => "Update bài thành công"]);
 }
Example #7
0
 public function update($id)
 {
     // save updated
     $record = $this->records->find($id);
     if (!$record) {
         Color::create(Input::all());
         return $this->respond($record);
     }
     $record->fill(Input::all())->save();
     return $this->respond($record);
 }
 public function edit($id)
 {
     $product = Product::find($id);
     $colors = Color::all();
     $types = Type::all();
     $selectedColors = $product->colors;
     $selectedType = $product->FK_type;
     foreach ($selectedColors as $color) {
         $arSelectedColors[] = $color->id;
     }
     return view('clothes.edit')->withProduct($product)->withTypes($types)->withColors($colors)->with('selectedColors', $arSelectedColors)->with('selectedType', $selectedType);
 }
 public function create()
 {
     $artists = ['default' => 'Choose an artist'] + Artist::orderby('name', 'ASC')->lists('name', 'id')->all();
     $eras = ['default' => 'Choose an era'] + Era::lists('name', 'id')->all();
     $categories = ['default' => 'Choose a category'] + Category::orderby('name', 'ASC')->lists('name', 'id')->all();
     $colors = ['default' => 'Choose a color'] + Color::orderby('colorEnglish', 'ASC')->lists('colorEnglish', 'id')->all();
     $styles = ['default' => 'Choose a style'] + Style::orderby('name', 'ASC')->lists('name', 'id')->all();
     $newestAuction = Auction::where('FK_status_id', '=', 1)->orWhere('FK_status_id', '=', 3)->orderBy('created_at', 'desc')->first();
     $timenow = Carbon::now()->addDays(1)->toDateString();
     //de datum nu
     return View::make('create')->with('artists', $artists)->with('eras', $eras)->with('categories', $categories)->with('colors', $colors)->with('styles', $styles)->with('newestAuction', $newestAuction)->with('timenow', $timenow);
 }
Example #10
0
 public function editar($id)
 {
     $header = 'Editar Producto';
     $breadcrumb = 'Editar Producto';
     $accion = 'Guardar';
     $producto = Producto::where('codigo', $id)->first();
     $grupo = Grupo::where('codigo', $producto->marca_id)->first();
     $padreGrupo = Grupo::where('id', $grupo->tipo)->first();
     $hijos = Grupo::where('tipo', $padreGrupo->id)->get();
     $padres = Grupo::where('tipo', 1)->get();
     $colores = Color::all();
     return view('productos.edit', compact('header', 'breadcrumb', 'padres', 'padreGrupo', 'hijos', 'producto', 'accion', 'colores'));
 }
 public function editTask($id)
 {
     if (Auth::check()) {
         $task = Task::findorfail($id);
         $discussions = Discussions::getDiscussionsForPost($id);
         $users = User::orderBy('id', 'desc')->get();
         $priorities = Priority::orderBy('id', 'asc')->get();
         $colors = Color::orderBy('id', 'asc')->get();
         $status = Status::orderBy('id', 'asc')->get();
         $data = array('task' => $task, 'discussions' => $discussions, 'users' => $users, 'priorities' => $priorities, 'colors' => $colors, 'status' => $status);
         return view('taskedit', $data);
     } else {
         return redirect('/')->withErrors('You must be authenticated to edit a task.');
     }
 }
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     view()->composer('*', function ($view) {
         $maxPrice = Product::orderBy('price', 'DESC')->first()->price;
         $minPrice = Product::orderBy('price', 'ASC')->first()->price;
         $colors = Color::all();
         $types = Type::all();
         $heartBag = User::getHeartBag();
         if (Auth::check()) {
             $view->with('bagContent', Auth::user()->bags->where('inBag', 1))->with('colors', $colors)->with('types', $types)->with('maxPrice', $maxPrice)->with('minPrice', $minPrice)->with('heartBag', $heartBag);
         } else {
             $view->with('bagContent', 0)->with('heartBag', 0)->with('minPrice', $minPrice)->with('maxPrice', $maxPrice)->with('colors', $colors)->with('types', $types);
         }
     });
 }
Example #13
0
 protected function getColorsOfProduct($array)
 {
     if (!is_array($array)) {
         $array = explode(",", $array);
     }
     if (count($array) > 1) {
         $count = 0;
         $colors = Color::select('id', 'name', 'image', 'code')->where('code', strtoupper($array[0]));
         foreach ($array as $item) {
             if ($count > 0) {
                 $colors_union = Color::select('id', 'name', 'image', 'code')->where('code', strtoupper($item));
                 $colors = $colors->unionAll($colors_union);
             }
             $count++;
         }
         $results = $colors->orderBy('name', 'asc')->get();
         return $results;
     } else {
         $results = Color::select('name', 'image')->where('code', $array)->get();
         return $results;
     }
 }
 /**
  * Get beers by their color values.  Can pass either start SRM value, start and end SRM values, or the color ID.
  *
  * @param Request $request
  * @return \Illuminate\Contracts\Routing\ResponseFactory|\Symfony\Component\HttpFoundation\Response
  */
 public function beers(Request $request)
 {
     $start = $request->get('start');
     $end = $request->get('end');
     $colorId = $request->get('color_id');
     if (!empty($start) && !empty($end)) {
         $beers = Beer::where('srm', '>=', $start)->where('srm', '<=', $end)->get();
         return response(['status' => 'ok', 'message' => 'Beers that fall in the SRM range of ' . $start . ' and ' . $end, 'beers' => $beers]);
     } else {
         if (!empty($start)) {
             $beers = Beer::where('srm', '=', $start)->get();
             return response(['status' => 'ok', 'message' => 'Beers that have the SRM value of ' . $start, 'beers' => $beers]);
         } else {
             if (!empty($colorId)) {
                 $color = Color::find($colorId);
                 if (!!$color) {
                     $beers = Beer::where('srm', '>=', $color->start)->where('srm', '<=', $color->end)->get();
                     return response(['status' => 'ok', 'message' => 'Beers that are of the color ' . $color->name . ' (id: ' . $colorId . ')', 'beers' => $beers]);
                 }
             }
         }
     }
     return response(['status' => 'failed', 'message' => 'Invalid data received.  You must provide the range of SRM values with the name start and end,' . 'or a color ID must be provided.  To get a list of colors including their ID, name, start and end range ' . 'perform a GET request on the color index route.', 'errors' => 'Bad values received'], 400);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $color = Color::findOrFail($id);
     $color->delete();
     return redirect()->route('admin.color.index')->with('alert-success', 'Delete complete');
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($slug, $id)
 {
     $list_color = Product::find($id)->color;
     $list_size = Product::find($id)->size;
     $size = Size::all();
     $color = Color::all();
     $products = Product::with(['category' => function ($querry) {
         $querry->addSelect('id', 'cate_name');
     }, 'brand' => function ($query) {
         $query->addSelect(['id', 'brand_name']);
     }, 'image' => function ($q) {
         $q->addSelect('product_id', 'image_name');
     }])->where('slug', $slug)->get();
     foreach ($products as $product) {
         return view('admin.product.edit', compact('product', 'list_color', 'list_size', 'size', 'color'));
     }
 }
 public function guardarTraduccion($request, $id)
 {
     $color = Color::findOrFail($id);
     $color->name = $request->input('name');
     $color->save();
     $languages = Language::get();
     foreach ($languages as $lang) {
         $nameLang = $request->input('name' . $lang->id);
         if (trim($nameLang) != "") {
             $languages_colors = LanguageColor::where('id_language', $lang->id)->where('id_color', $color->id)->first();
             if (!isset($languages_colors->id)) {
                 $languages_colors = new LanguageColor();
             }
             $languages_colors->id_language = $lang->id;
             $languages_colors->id_color = $color->id;
             $languages_colors->name = $nameLang;
             $languages_colors->save();
         } else {
             $languages_colors = LanguageColor::where('id_language', $lang->id)->where('id_color', $color->id)->first();
             if (isset($languages_colors->id)) {
                 $languages_colors->delete();
             }
         }
     }
 }
Example #18
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     Color::destroy($id);
 }
Example #19
0
 public function index()
 {
     $colores = Color::all();
     return response()->json($colores);
 }
Example #20
0
 public function destroy(Project $project, Color $color)
 {
     $color->delete();
     return redirect()->back();
 }
 public function getCart()
 {
     $colors = Color::all();
     $sizes = Size::all();
     $nav = new category();
     $menu_top = $nav->menu_top($nav->all()->toArray());
     $product = new Product();
     $all = $product->getall()->take(5);
     return view('frontend.pages.cart', array('colors' => $colors, 'sizes' => $sizes, 'menu_top' => $menu_top, 'all' => $all));
 }
Example #22
0
 /**
  * Delete the given Color.
  *
  * @param  int      $id
  * @return Redirect
  */
 public function getDelete($id = null)
 {
     $color = Color::destroy($id);
     // Redirect to the group management page
     return redirect('admin/colors')->with('success', Lang::get('message.success.delete'));
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     //
     $cat_id = new category();
     $category = $cat_id->all();
     $color = Color::all();
     $size = Size::all();
     $product = Product::find($id);
     return view('backend.pages.product.edit2', array('category' => $category, 'product' => $product, 'color' => $color, 'size' => $size));
 }
Example #24
0
 public function save_product($domain, Request $request)
 {
     if ($request->id) {
         $product = Product::find($request->id);
     } else {
         $product = new Product();
     }
     $product->description = $request->description;
     $product->title = $request->title;
     $product->content = $request->product_content;
     $product->author_id = $this->user->id;
     $product->tags = $request->tags_string;
     $product->category_id = $request->category_id;
     if ($request->video_url) {
         $product->url = $request->video_url;
         $product->image_name = $request->video_name;
         $product->thumb_url = $request->thumb_url;
     } else {
         $product->url = $request->image_url;
         $product->image_name = $request->image_name;
         $product->thumb_name = $request->thumb_name;
         $product->thumb_url = $request->thumb_url;
     }
     $product->type = 2;
     $product->save();
     foreach ($product->colors as $color) {
         $color->delete();
     }
     $colorStr = $request->colorStr;
     $colors = explode("#", $colorStr);
     foreach ($colors as $c) {
         $color = new Color();
         $color->product_id = $product->id;
         $color->value = $c;
         $color->save();
     }
     return $this->respond(['message' => "Đăng bài thành công", "url" => convert_vi_to_en($product->title) . "-" . $product->id]);
 }
Example #25
0
 /**
  * Get specified resources in AJAX
  *
  * @param  \Illuminate\Http\Request $request
  * @return \Illuminate\Http\Response
  */
 private function search($item, $type = null)
 {
     $search = Color::like('name', $item)->select('id', 'name', 'code', 'image')->get();
     return $search;
 }
Example #26
0
 /**
  * Updates existing project in database
  *
  * @param Project $project
  * @param Request $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function update(Project $project, Request $request)
 {
     if (Gate::denies('update-project', $project)) {
         abort(403);
     }
     $data = $request->all();
     if ($data['_type'] == 'color') {
         Color::create($data);
     }
     $project->update($data);
     return redirect()->action('ProjectController@edit', $project->id);
 }