Пример #1
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($slug)
 {
     //
     $producto = Productos::Where('slug', $slug)->first();
     //dd($producto);
     return view('store.show', compact('producto'));
 }
Пример #2
0
 /**
  * Esta funcion se encarga de eliminar un 
  * producto de la base de datos
  *
  * @param id del producto
  *
  */
 public function delete($id)
 {
     if ($producto = Productos::find($id)) {
         $producto->delete();
     } else {
         //SI NO EXISTE ?
     }
     //QUE HACER DESPUES DE LA ACCION?
 }
Пример #3
0
 public function productos(Request $request)
 {
     $productos = Productos::query()->select('productos.*', 'T.tipo')->join('tipos AS T', 'productos.tipo_id', '=', 'T.id')->paginate(6);
     if ($request->ajax()) {
         return view('Frontend.products.product', ['productos' => $productos]);
         #return view('Frontend.products.product',['productos' => $productos])->header('Content-Type',$productos->nextPageUrl());
         /*return response()->json([
         			'view'=>view('Frontend.products.product',['productos' => $productos]),
         		'url'=>$productos->nextPageUrl()]);*/
     }
     return view('Frontend.products.products', ['productos' => $productos]);
 }
Пример #4
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     //
     $productToDelete = Productos::find($id);
     $fecha = date('Y-m-d h:m:s');
     $producToDelete = Productos::where('id', '=', $id)->update(['deleted_at' => $fecha]);
     Flash::info("El producto " . $productToDelete->nombre . " ha sido eliminado de manera correcta.!");
     return redirect()->route('admin.products.index');
 }
Пример #5
0
 public function getProductos()
 {
     $productos = Productos::all();
     return response()->json($productos);
 }
Пример #6
0
 /**
  * Run the Products table seeds.
  *
  * @return void
  */
 public function run()
 {
     $data = array(['name' => 'Playera 1', 'slug' => 'playera-1', 'description' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Delectus repellendus doloribus molestias odio nisi! Aspernatur eos saepe veniam quibusdam totam.', 'extract' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit.', 'price' => 275.0, 'image' => 'http://www.truffleshuffle.co.uk/store/images_high_res/Mens_Red_Batman_Graffiti_Logo_T_Shirt_hi_res.jpg', 'visible' => 1, 'created_at' => new DateTime(), 'updated_at' => new DateTime(), 'category_id' => 1], ['name' => 'Playera 2', 'slug' => 'playera-2', 'description' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Delectus repellendus doloribus molestias odio nisi! Aspernatur eos saepe veniam quibusdam totam.', 'extract' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit.', 'price' => 255.0, 'image' => 'http://www.truffleshuffle.co.uk/store/images_high_res/Mens_Blue_Distressed_Superman_Logo_T_Shirt_hi_res.jpg', 'visible' => 1, 'created_at' => new DateTime(), 'updated_at' => new DateTime(), 'category_id' => 1], ['name' => 'Playera 3', 'slug' => 'playera-3', 'description' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Delectus repellendus doloribus molestias odio nisi! Aspernatur eos saepe veniam quibusdam totam.', 'extract' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit.', 'price' => 300.0, 'image' => 'http://img5a.flixcart.com/image/t-shirt/f/g/q/fsbk-bruce-lee-sayitloud-xl-700x700-imadtkffxfhgsday.jpeg', 'visible' => 1, 'created_at' => new DateTime(), 'updated_at' => new DateTime(), 'category_id' => 1], ['name' => 'Playera 4', 'slug' => 'playera-4', 'description' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Delectus repellendus doloribus molestias odio nisi! Aspernatur eos saepe veniam quibusdam totam.', 'extract' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit.', 'price' => 475.0, 'image' => 'http://rlv.zcache.com/funny_computer_geek_t_shirt_tshirt-r537052a6a7b94b028e47b274c099fe24_804g5_324.jpg', 'visible' => 1, 'created_at' => new DateTime(), 'updated_at' => new DateTime(), 'category_id' => 2], ['name' => 'Playera 5', 'slug' => 'playera-5', 'description' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Delectus repellendus doloribus molestias odio nisi! Aspernatur eos saepe veniam quibusdam totam.', 'extract' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit.', 'price' => 280.0, 'image' => 'https://www.nerdyshirts.com/media/catalog/product/cache/1/image/400x445/9df78eab33525d08d6e5fb8d27136e95/g/e/geek_1.jpg', 'visible' => 1, 'created_at' => new DateTime(), 'updated_at' => new DateTime(), 'category_id' => 2], ['name' => 'Playera 6', 'slug' => 'playera-6', 'description' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Delectus repellendus doloribus molestias odio nisi! Aspernatur eos saepe veniam quibusdam totam.', 'extract' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit.', 'price' => 275.0, 'image' => 'http://bobstshirtcompany.net/media/catalog/product/cache/1/image/650x650/9df78eab33525d08d6e5fb8d27136e95/i/_/i_know_html.jpg', 'visible' => 1, 'created_at' => new DateTime(), 'updated_at' => new DateTime(), 'category_id' => 2], ['name' => 'Playera 7', 'slug' => 'playera-7', 'description' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Delectus repellendus doloribus molestias odio nisi! Aspernatur eos saepe veniam quibusdam totam.', 'extract' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit.', 'price' => 275.0, 'image' => 'http://www.koszulkomat.eu/images4/preview/14/1430_7-0.png', 'visible' => 1, 'created_at' => new DateTime(), 'updated_at' => new DateTime(), 'category_id' => 1], ['name' => 'Playera 8', 'slug' => 'playera-8', 'description' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Delectus repellendus doloribus molestias odio nisi! Aspernatur eos saepe veniam quibusdam totam.', 'extract' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit.', 'price' => 275.0, 'image' => 'http://cdn.somethinggeeky.com/assets/images/products/amazonlarge/4ffed02898033.jpg', 'visible' => 1, 'created_at' => new DateTime(), 'updated_at' => new DateTime(), 'category_id' => 2]);
     Productos::insert($data);
 }
Пример #7
0
 public function destroy($id)
 {
     try {
         DB::beginTransaction();
         if (Productos::destroy($id)) {
             DB::commit();
             $respuesta['registros'] = array();
             $respuesta['mensaje'] = 'Registro eliminado correctamente';
             $respuesta['resultado'] = true;
             return $respuesta;
         } else {
             DB::rollback();
             $respuesta['registros'] = array();
             $respuesta['mensaje'] = 'Error al tratar de eliminar el registro';
             $respuesta['resultado'] = false;
             return $respuesta;
         }
     } catch (\Exception $e) {
         $respuesta['registros'] = array();
         $respuesta['mensaje'] = 'Error general: ' . $e;
         $respuesta['resultado'] = false;
         return $respuesta;
     }
 }