/** * 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); }); }
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)); }
/** * 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'); }
/** * 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); }