Ejemplo n.º 1
0
 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     parent::boot($router);
     $router->bind('carpets', function ($id) {
         return Carpet::findOrFail($id);
     });
 }
Ejemplo n.º 2
0
 public function get($id = '')
 {
     //$carpet = Carpet::findOrFail(3);
     $carpets = Carpet::all();
     $return_json = "";
     foreach ($carpets as $carpet) {
         $data = json_decode($carpet);
         foreach ($data as $key => $entry) {
             if ($key == 'id' && $entry == $carpet->id) {
                 $data->types = array('type' => $carpet->types);
                 $data->prices = array('price' => $carpet->prices);
             }
         }
         $return_json[] = $data;
     }
     return Response()->json(array('Carpet' => $return_json));
 }
Ejemplo n.º 3
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update(CarpetRequest $request, Carpet $carpet)
 {
     $carpet->update($request->all());
     return redirect('admin/carpets');
 }
Ejemplo n.º 4
0
 /**
  * get last updates based on the date and time.
  * @param $date date
  * @param $time time
  * @return json
  */
 public function getUpdate($date, $time)
 {
     $carpets = Carpet::where('updated_at', '>=', $date . ' ' . $time)->get();
     //dd($carpets);
     return self::makeJson($carpets);
 }