Пример #1
0
 public static function variables($variables, $producto)
 {
     if (!$variables->isEmpty()) {
         $lista_variable1 = atributos_sub::where('atributo_id', '=', $producto->atributo_1)->lists('variable', 'id')->toArray();
         if ($producto->atributo_2 > 0) {
             $lista_variable2 = atributos_sub::where('atributo_id', '=', $producto->atributo_2)->lists('variable', 'id')->toArray();
         } else {
             $lista_variable2[] = '';
         }
         foreach ($variables as $variable) {
             $variable1[] = $variable->variable_1;
             $variable2[] = $variable->variable_2;
         }
     } else {
         $variable1 = '';
         $variable2 = '';
         $lista_variable1[] = '';
         $lista_variable2[] = '';
     }
     return array('variable1' => $variable1, 'variable2' => $variable2, 'lista_variable1' => $lista_variable1, 'lista_variable2' => $lista_variable2);
 }
Пример #2
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int $id
  * @return Response
  */
 public function edit($id)
 {
     //
     $producto = productos::findorfail($id);
     $marcas = marcas::lists('marca', 'id')->all();
     $categorias = categorias::lista(1);
     $categorias_padre = categorias::lista_padres(1);
     $atributos = atributos::lists('atributo', 'id')->all();
     $impuestos = impuestos::lists('impuesto', 'id')->all();
     $block = '';
     $imagen = $producto->imagen;
     $variables = productos_configurables::where('producto_id', '=', $producto->id)->get();
     if (!$variables->isEmpty()) {
         $lista_variable1 = atributos_sub::where('atributo_id', '=', $producto->atributo_1)->lists('variable', 'id')->toArray();
         $lista_variable2 = atributos_sub::where('atributo_id', '=', $producto->atributo_2)->lists('variable', 'id')->toArray();
         foreach ($variables as $variable) {
             $variable1[] = $variable->variable_1;
             $variable2[] = $variable->variable_2;
         }
     } else {
         $variable1 = '';
         $variable2 = '';
         $lista_variable1[] = '';
         $lista_variable2[] = '';
     }
     return view('app/productos/producto_edit', compact(['producto', 'marcas', 'categorias', 'atributos', 'impuestos', 'categorias_padre', 'imagen', 'block', 'variable1', 'variable2', 'lista_variable1', 'lista_variable2']));
 }
Пример #3
0
 public function variables(Request $request)
 {
     //
     $variables = atributos_sub::where('atributo_id', '=', $request->id)->get();
     foreach ($variables as $variable) {
         $lista_variables[] = '<option value="' . $variable->id . '">' . $variable->variable . '</option>';
     }
     return response()->json(['variables' => $lista_variables]);
 }