/** * Create a unique slug for ad added by user * * @param string $title * @return string $slug */ public function makeUserAdSlug($title) { $slug = str_replace(' ', '_', $title); do { $isSlugExists = UserClassicAd::findBySlug($slug); if ($isSlugExists->count() === 0) { break; } else { $slug = time() . '_' . $slug; } } while (true); return $slug; }
/** * Show the single ad added by user * * @return Response */ public function showSingleAd($classic_ad_slug, $user_classic_ad_slug) { $this->view_data['classic_ad'] = ClassicAd::findBySlug($classic_ad_slug); $this->view_data['user_classic_ad'] = UserClassicAd::findBySlug($user_classic_ad_slug); $this->view_data['heading'] = $this->view_data['user_classic_ad']->title; $this->view_data['page_title'] .= ' - ' . $this->view_data['classic_ad']->title . ' - ' . $this->view_data['user_classic_ad']->title; $this->view_data['sub_heading'] = 'Added By <strong>' . $this->view_data['user_classic_ad']->advertiser_name . '</strong>'; return view($this->view_data['view_path_root'] . '.single_ad', $this->view_data); }