public function getPropertyFromListing($ListingId) { $list = Listing::where('listing_id', '=', $ListingId)->first(); $location = $list->location; $listings = $location->listing; return view('listingByProperty', compact('listings'), compact('location')); }
public function removeListing($id) { if (Auth::guest()) { return redirect()->route('home'); } $listing = Listing::where('id', $id)->where('user_id', Auth::user()->id)->first(); if ($listing) { $listing->delete(); flash()->success("Successfully removed your listing"); return redirect()->back(); } else { flash()->error("You cannot remove that listing"); return redirect()->back(); } }