public function sendContactEmail(Request $request) { if (Auth::check()) { $userRecieving = User::findOrFail($request->recievingUser); $userSending = Auth::user(); $listingInfo = Listing_Info::findOrFail($request->listing_id); Mail::send('emails.contactLandlord', ['userSending' => $userSending, 'userRecieving' => $userRecieving, 'propertyId', 'listingInfo' => $listingInfo], function ($m) use($userSending, $userRecieving) { $m->from('*****@*****.**', 'Homestead Listing Bot'); $m->to($userRecieving->email, $userRecieving->name)->subject($userSending->first_name . ' ' . $userSending->last_name . ' wants to talk about your property!'); }); return redirect('houseTemplate/' . $request->listing_id); } else { return redirect('signIn')->withErrors('You need to be signed in to contact the owner!'); } }
public function searchFilters(Request $request) { if ($request->ajax()) { //dd($request->all()); $country = Input::get('country'); $region = Input::get('region'); $maxPrice = Input::get('maxPrice'); $minPrice = Input::get('minPrice'); $rooms = Input::get('rooms'); $bathrooms = Input::get('bathrooms'); $kitchen = Input::has('hasKitchen') ? 1 : null; $laundry = Input::has('laundry') ? 1 : null; $internet = Input::has('internet') ? 1 : null; $water = Input::has('water') ? 1 : null; $electricity = Input::has('hydro') ? 1 : null; $smoke = Input::has('smoke') ? 1 : null; $yard = Input::has('yard') ? 1 : null; $pets = Input::has('nopets') ? 1 : null; $dogs = Input::has('dogs') ? 1 : null; $cats = Input::has('cats') ? 1 : null; $other_pets = Input::has('other') ? 1 : null; $numMates = Input::get('MaxNumRoommates'); if ($maxPrice == 2000) { $maxPrice = 99999; } //$locations = Location::where('city', $region)->get(); //$listings = $locations->listing(); $query = Listing_Info::whereIfNotNull('num_bedrooms_total', "<=", $rooms)->whereIfNotNull('price_monthly', "<=", $maxPrice)->whereIfNotNull('price_monthly', ">=", $minPrice)->whereIfNotNull('num_bathrooms_total', "<=", $bathrooms)->whereIfNotNull('has_laundry', "=", $laundry)->whereIfNotNull('owner_pays_internet', "=", $internet)->whereIfNotNull('has_kitchen', "=", $kitchen)->whereIfNotNull('owner_pays_electricity', "=", $electricity)->whereIfNotNull('owner_pays_water', "=", $water)->whereIfNotNull('has_laundry', "=", $laundry)->whereIfNotNull('has_yard', "=", $yard)->whereIfNotNull('owner_has_pets', "=", $pets)->whereIfNotNull('allowed_dogs', "=", $dogs)->whereIfNotNull('allowed_cats', "=", $cats)->whereIfNotNull('allowed_other_pets', "=", $other_pets); if ($numMates == "99") { $query = $query->where('num_roommates_max', "<=", "99"); } else { $query = $query->where('num_roommates_max', "=", $numMates); } $listingInfo = $query->get(); $listings = array(); $long = 0; $lat = 0; $count = 0; foreach ($listingInfo as $list) { //$listings = Location::where($list->listing->location.city, '=', $region); $location = $list->listing->location; if ($country != "all") { if ($location['city'] == $region && $location['country'] == $country) { //dd($list); array_push($listings, $location); $count = $count + 1; $long = $long + $location->longitude; $lat = $lat + $location->latitude; } } else { array_push($listings, $location); $count = $count + 1; $long = $long + $location->longitude; $lat = $lat + $location->latitude; } } if ($count != 0) { $long = $long / $count; $lat = $lat / $count; } array_push($listings, $lat); array_push($listings, $long); //dd($internet); // dd($listings); return response()->json(['data' => $listings]); } }
public function getSearchListings($searchId) { $search = Saved_Search::where('saved_search_id', '=', $searchId)->first(); $topPrice = $search->price_monthly_max; if ($topPrice == 2000) { $topPrice = 5000000; } $listings = Listing_Info::whereIfNotNull('num_bedrooms_total', "=", $search->num_bedrooms_total)->whereIfNotNull('price_monthly', "<=", $search->price_monthly_min)->whereIfNotNull('price_monthly', ">=", $topPrice)->whereIfNotNull('num_bathrooms_total', "=", $search->num_bathrooms_total)->whereIfNotNull('has_laundry', "=", $search->has_laundry)->whereIfNotNull('owner_pays_internet', "=", $search->owner_pays_internet)->whereIfNotNull('has_kitchen', "=", $search->has_kitchen)->whereIfNotNull('owner_pays_electricity', "=", $search->owner_pays_electricity)->whereIfNotNull('owner_pays_water', "=", $search->owner_pays_water)->whereIfNotNull('owner_has_pets', "=", $search->owner_has_pets)->whereIfNotNull('allowed_dogs', "=", $search->allowed_dogs)->whereIfNotNull('allowed_cats', "=", $search->allowed_cats)->whereIfNotNull('allowed_other_pets', "=", $search->allowed_other_pets)->get(); return view('listingBySearch', compact('listings')); }