/** * Show the form for creating a new resource. * * @return Response */ public function create($id) { $user_id = Auth::user()->id; $user_role = User::findOrfail($user_id); $bedroom = Property::findOrFail($id); return view('admin.properties.bedrooms.index', compact('bedroom', 'user_role')); }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show() { $user_id = Auth::user()->id; $user_role = User::findOrfail($user_id); $properties = Property::select('id', 'name', 'image', 'status', 'num_bedrooms', 'description', 'country_id', 'service_id', 'state_id', 'city_id', 'property_type_id', 'user_id')->with('country')->with('service')->with('state')->with('city')->with('property_type')->with('user')->orderBy('name', 'ASC')->get(); return view('admin.properties.ameneties.show', compact('properties', 'service', 'state', 'city', 'property_type', 'user', 'user_role')); }
/** * Show the form for creating a new resource. * * @return Response */ public function create($id, Redirector $redirector) { $rooms = Bedroom::select('property_id')->where('property_id', '=', $id)->count(); $Arooms = Property::select('id', 'num_bedrooms')->where('id', '=', $id)->get('num_bedrooms'); foreach ($Arooms as $bedrooms) { $num = $bedrooms->num_bedrooms; if ($rooms < $num) { $user_id = Auth::user()->id; $user_role = User::findOrfail($user_id); $bedroom = Property::findOrFail($id); return view('admin.properties.bedrooms.index', compact('user_role', 'bedroom')); } else { Session::flash('message', "Ya se agregaron los {$bedrooms->num_bedrooms} cuartos, si la casa tiene mas cuartos modifica el numero de cuartos de la casa."); return $redirector->back(); } } }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id, Request $request) { $user_id = Auth::user()->id; $user_role = User::findOrfail($user_id); $property = Property::findOrFail($id); $property->delete(); $message = $property->name . ' Fue eliminado de nuestros registros'; if ($request->ajax()) { return response()->json(['id' => $property->id, 'message' => $message]); } Session::flash('message', $property->name . " Fue eliminado de nuestros registros"); return redirect()->route('admin.properties.show', compact('user_role')); }
/** * Display the specified resource. * * @param int $id * @return Response */ public function casasassisting() { $properties = Property::select('id', 'name', 'image', 'status', 'num_bedrooms', 'description', 'slogan', 'country_id', 'service_id', 'state_id', 'city_id', 'property_type_id', 'user_id')->with('country')->with('service')->with('state')->with('city')->with('property_type')->with('user')->orderBy('name', 'ASC')->get(); return view('Acasas', compact('properties', 'service', 'state', 'city', 'property_type', 'user', 'user_role')); }
public function search(Request $request) { $service_id = $request->service; $country_id = $request->select; $state_id = $request->select2; $city_id = $request->select3; //Si viene el service y la ciudad if (!empty($service_id) && !empty($city_id)) { $service = Service::findOrFail($service_id); $get_Jalisco = State::findOrFail(51); $get_Nayarit = State::findOrFail(52); if ($city_id == '-- City --') { if ($state_id == 'Jalisco') { $properties = Property::select('id', 'name', 'image', 'status', 'num_bedrooms', 'description', 'slogan', 'country_id', 'service_id', 'state_id', 'city_id', 'property_type_id', 'user_id')->with('country')->with('service')->with('state')->with('city')->with('property_type')->with('user')->where('service_id', '=', $service_id)->where('state_id', '=', $get_Jalisco->id)->get(); $casas = count($properties); if ($casas) { return view('searhResorts', compact('properties', 'service', 'state', 'city', 'property_type', 'service')); } else { Session::flash('message', " No se encontraron Resorts con los valores buscados."); return view('searhResorts', compact('properties', 'service', 'state', 'city', 'property_type', 'service')); } } elseif ($state_id == 'Nayarit') { $properties = Property::select('id', 'name', 'image', 'status', 'num_bedrooms', 'description', 'slogan', 'country_id', 'service_id', 'state_id', 'city_id', 'property_type_id', 'user_id')->with('country')->with('service')->with('state')->with('city')->with('property_type')->with('user')->where('service_id', '=', $service_id)->where('state_id', '=', $get_Nayarit->id)->get(); $casas = count($properties); if ($casas) { return view('searhResorts', compact('properties', 'service', 'state', 'city', 'property_type', 'service')); } else { Session::flash('message', " No se encontraron Resorts con los valores buscados."); return view('searhResorts', compact('properties', 'service', 'state', 'city', 'property_type', 'service')); } } } $properties = Property::select('id', 'name', 'image', 'status', 'num_bedrooms', 'description', 'slogan', 'country_id', 'service_id', 'state_id', 'city_id', 'property_type_id', 'user_id')->with('country')->with('service')->with('state')->with('city')->with('property_type')->with('user')->where('service_id', '=', $service_id)->where('city_id', '=', $city_id)->get(); $casas = count($properties); if ($casas) { return view('searhResorts', compact('properties', 'service', 'state', 'city', 'property_type', 'service')); } else { Session::flash('message', " No se encontraron Resorts con los valores buscados."); return view('searhResorts', compact('properties', 'service', 'state', 'city', 'property_type', 'service')); } } else { if (!empty($service_id) && !empty($country_id) && !empty($state_id)) { $service = Service::findOrFail($service_id); $get_Jalisco = State::findOrFail(51); $get_Nayarit = State::findOrFail(52); if ($state_id == 'Jalisco') { $properties = Property::select('id', 'name', 'image', 'status', 'num_bedrooms', 'description', 'slogan', 'country_id', 'service_id', 'state_id', 'city_id', 'property_type_id', 'user_id')->with('country')->with('service')->with('state')->with('city')->with('property_type')->with('user')->where('service_id', '=', $service_id)->where('state_id', '=', $get_Jalisco->id)->get(); $casas = count($properties); if ($casas) { return view('searhResorts', compact('properties', 'service', 'state', 'city', 'property_type', 'service')); } else { Session::flash('message', " No se encontraron Resorts con los valores buscados."); return view('searhResorts', compact('properties', 'service', 'state', 'city', 'property_type', 'service')); } } elseif ($state_id == 'Nayarit') { $properties = Property::select('id', 'name', 'image', 'status', 'num_bedrooms', 'description', 'slogan', 'country_id', 'service_id', 'state_id', 'city_id', 'property_type_id', 'user_id')->with('country')->with('service')->with('state')->with('city')->with('property_type')->with('user')->where('service_id', '=', $service_id)->where('state_id', '=', $get_Nayarit->id)->get(); $casas = count($properties); if ($casas) { return view('searhResorts', compact('properties', 'service', 'state', 'city', 'property_type', 'service')); } else { Session::flash('message', " No se encontraron Resorts con los valores buscados."); return view('searhResorts', compact('properties', 'service', 'state', 'city', 'property_type', 'service')); } } else { $properties = Property::select('id', 'name', 'image', 'status', 'num_bedrooms', 'description', 'slogan', 'country_id', 'service_id', 'state_id', 'city_id', 'property_type_id', 'user_id')->with('country')->with('service')->with('state')->with('city')->with('property_type')->with('user')->where('service_id', '=', $service_id)->where('country_id', '=', 1)->get(); $casas = count($properties); if ($casas) { return view('searhResorts', compact('properties', 'service', 'state', 'city', 'property_type', 'service')); } else { Session::flash('message', " No se encontraron Resorts con los valores buscados."); return view('searhResorts', compact('properties', 'service', 'state', 'city', 'property_type', 'service')); } } } else { if (!empty($service_id)) { $service = Service::findOrFail($service_id); $properties = Property::select('id', 'name', 'image', 'status', 'num_bedrooms', 'description', 'slogan', 'country_id', 'service_id', 'state_id', 'city_id', 'property_type_id', 'user_id')->with('country')->with('service')->with('state')->with('city')->with('property_type')->with('user')->where('service_id', '=', $service_id)->get(); $casas = count($properties); if ($casas) { return view('searhResorts', compact('properties', 'service', 'state', 'city', 'property_type', 'service')); } else { Session::flash('message', " No se encontraron Resorts con los valores buscados."); return view('searhResorts', compact('properties', 'service', 'state', 'city', 'property_type', 'service')); } } else { return redirect()->back(); } } } }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id, Request $request) { $property = Property::findOrFail($id); $property->delete(); $message = $property->name . ' Fue eliminado de nuestros registros'; if ($request->ajax()) { return response()->json(['id' => $property->id, 'message' => $message]); } Session::flash('message', $property->id . " Fue eliminado de nuestros registros"); return redirect()->route('admin.properties .index'); }