/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($public_id) { $unidad = Unidad::where('account_id', '=', Auth::user()->account_id)->where('public_id', $public_id)->first(); $unidad->delete(); $message = "Unidad eliminada con éxito"; Session::flash('message', $message); return Redirect::to('unidades'); }
public function setName($name) { if (is_null($name)) { $this->fv_name = "Nombre " . ERROR_NULL . "<br>"; return; } $categories = Unidad::where('account_id', $this->getAccountId())->get(); foreach ($categories as $cat) { if ($cat->getName() == $name) { $this->fv_name = "La unidad ya existe"; } } if ($this->fv_name) { return; } $this->fv_name = null; $this->name = $name; return $this; }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($publicId) { $product = Product::scope($publicId)->with('category')->firstOrFail(); $unidad = Unidad::where('id', $product->unidad_id)->first(); $data = array('title' => 'Ver Producto', 'product' => $product, 'unidad' => $unidad); if ($product->is_product == 1) { return View::make('productos.show', $data); } else { return View::make('servicios.show', $data); } }