public function getCommunity($community) { $community = \App\Community::where('community', '=', $community)->with('properties')->first(); if (is_null($community)) { abort(404); } $properties = \App\Property::whereHas('community', function ($q) use($community) { $q->where('community', '=', $community['community']); $q->where('Status', '!=', 'closed'); })->paginate(15); return view('pages.communityDetail')->with(['community' => $community, 'properties' => $properties, 'communities' => $this->communities, 'communitySelect' => $this->communitySelect]); }
/** * Execute the job. * * @return void */ public function handle() { $community = $this->property['CommunityName']; if ($community !== 'None') { $createdCommunity = \App\Community::where('community', '=', $community)->first(); if (is_null($createdCommunity)) { $this->createProperty->community()->create(['community' => $community]); } else { $this->createProperty->community()->sync([$createdCommunity->id]); } } }
public function filter(Request $request) { $allCommunities = $request->communities; $communities = Community::where('city_id', $request->city)->get(); $requestedInfo = $request; if ($request->from == '' || $request->from == 0) { $from = 1.0E+17; } else { $from = $request->from; } if (sizeof($allCommunities) > 0) { $posts = Post::with('author', 'comments.author', 'community')->where('sold', NULL)->whereBetween('price', array($request->to, $from))->whereIn('community_id', $allCommunities)->where('city_id', $request->city)->paginate(12); } else { $posts = Post::with('author', 'comments.author', 'community')->where('sold', NULL)->whereBetween('price', array($request->to, $from))->where('city_id', $request->city)->paginate(12); } $city = City::where('id', $request->city)->get(); return view('city.home', ['posts' => $posts, 'city' => $city, 'communities' => $communities, 'request' => $requestedInfo]); }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($community, $id) { $post = Post::with('author', 'comments.author', 'community')->where('id', $id)->get(); $comments = Comment::with('author')->where('post_id', $id)->get(); $community = Community::where("id", $community)->get(); $city = City::where('id', $post[0]->city_id)->get(); return view('posts.show', ['post' => $post, "comments" => $comments, 'community' => $community, 'city' => $city]); }
public function showPosts($community) { $posts = Post::with('author', 'comments.author', 'community')->where('sold', NULL)->orderBy('created_at', 'desc')->where('community_id', $community)->paginate(12); $community = Community::where('id', $community)->get(); return view('community.home', ['posts' => $posts, 'community' => $community]); }