public function home() { $alerts = AlertType::all(); /*$products = DB::select(' SELECT * FROM products AS p1 WHERE quantity <= ( SELECT stock_alert FROM products AS p2 WHERE p2.id = p1.id )' );*/ $products = DB::table('products as p1')->whereRaw('p1.quantity <= (select stock_alert from products AS p2 where p2.id = p1.id)')->get(); $productNumber = count($products); return view('home.index', compact('alerts', 'products', 'productNumber')); }
public function add($petId) { $pet = Pet::find($petId); $alertsType = AlertType::lists('title', 'id'); return view('alert.create', compact('pet', 'alertsType')); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $alertType = AlertType::find($id); $alertType->delete(); Session::flash('message', 'Tipo de alerta eliminado correctamente'); return Redirect::to('/alertType'); }