get(); $posts = Post::translatedIn(app()->getLocale())->ordered()->paginate(3); $pages = Page::featured()->translatedIn(app()->getLocale())->ordered()->paginate(6); return view('public.index', compact('properties', 'posts', 'pages')); } public function properties(Category $category) { $title = $category->name; $filter = new Filter(['category' => $category->id]); session()->flash('filter', $filter); $properties = $category->properties()->latest()->paginate(10); return view('public.properties', compact('properties', 'title')); } public function property(Category $category, Property $property) { return view('public.property', compact('category', 'property')); } public function getPage(Request $request) { $url = substr(parse_url(LaravelLocalization::getNonLocalizedURL(), PHP_URL_PATH), 1); $page = Page::whereTranslation('url', $url)->first(); return view('public.page', compact('page')); } public function search(Request $request) { $filter = new Filter($request->all()); session()->flash('filter', $filter); $properties = new Property; if($filter->search) { $properties = $properties->whereTranslationLike('title', '%'.$filter->search.'%'); } if($filter->category) { $properties = $properties->where('category_id', '=', $filter->category); } if($filter->type) { $properties = $properties->where('type', '=', $filter->type); } if($filter->place) { $properties = $properties->where('place_id', '=', $filter->place); } if($filter->area) { $properties = $properties->where('area_id', '=', $filter->area); } if($filter->price) { $properties = $properties->where('price', '<=', $filter->price); } if($filter->surface) { $properties = $properties->where('surface', '>=', $filter->surface); } $properties = $properties->orderBy('price')->paginate(10); $title = trans('global.search'); return view('public.properties', compact('properties', 'title')); } public function specialOffer() { $title = trans('navigation.special-offer'); $properties = Property::whereStatus('discount')->latest()->paginate(10); return view('public.properties', compact('properties', 'title')); } public function aboutUs() { return view('public.about-us'); } public function posts() { $posts = Post::translatedIn(app()->getLocale())->ordered()->paginate(6); return view('public.posts', compact('posts', 'title')); } public function post(Post $post) { $posts = Post::translatedIn(app()->getLocale())->where('id', '!=', $post->id)->ordered()->paginate(5); return view('public.post', compact('post', 'posts')); } public function projects() { $pages = Page::translatedIn(app()->getLocale())->ordered()->paginate(9); return view('public.projects', compact('pages', 'title')); } public function project(Page $page) { $pages = Page::translatedIn(app()->getLocale())->where('id', '!=', $page->id)->ordered()->paginate(5); return view('public.project', compact('page', 'pages')); } public function getContact() { return view('public.contact'); } public function getThankYou() { return view('public.thank-you'); } public function PrivacyPolicy() { return view('public.privacy-policy'); } public function TermsConditions() { return view('public.terms-conditions'); } public function createProperty() { return view('public.create-property'); } public function storeProperty(Request $request) { $data = $request->all(); if (empty($data['check_email'])) { Mail::send('emails.property', compact('data'), function($message) use ($data) { $message->to(config('mail.to'))->replyTo($data['email'], $data['name'])->subject(config('mail.subject')); foreach ($data['images'] as $image) { if($image) $message->attach($image->getRealPath(), array('as' => $image->getClientOriginalName())); } }); return redirect()->route('public.thank.you'); } } public function mail(Request $request) { $data = $request->all(); if (empty($data['check_email'])) { Mail::send('emails.contact', compact('data'), function($message) use ($data) { $message->to(config('mail.to'))->replyTo($data['email'], $data['name'])->subject(config('mail.subject')); if(array_key_exists ('file', $data)) { $message->attach($data['file']->getRealPath(), array( 'as' => $data['file']->getClientOriginalName() )); } }); return redirect()->route('public.thank.you'); } } public function newsletter(Request $request) { $data = $request->all(); if (empty($data['check_email'])) { Mail::send('emails.newsletter', compact('data'), function($message) use ($data) { $message->to(config('mail.to'))->replyTo($data['email'])->subject(config('mail.subject-newsletter')); }); return redirect()->route('public.thank.you'); } } public function areas($id) { return Place::find($id)->areas()->orderBy('name')->lists('name', 'id'); } }