public function __construct() { $this->site_infos = Site_infos::first(); $this->destination = Country::select('id', 'name', 'url')->where('status', 'Active')->get(); $this->menu = Page::where('status', 'Active')->where('parent_id', 0)->where('status', 'Active')->get(); /** * find parent id on the menu and concatenate related sub menu to Array * */ foreach ($this->menu as $key => $m) { $this->menu[$key]->sub_menu = Page::where('parent_id', $m->id)->where('status', 'Active')->get()->toArray(); } /** * find the country related category */ foreach ($this->destination as $key => $d) { $this->destination[$key]->category = category::select('name', 'url')->where('country_id', $d->id)->where('status', 'Active')->get()->toArray(); } }
protected function __checkForDuplicateUrl($id, $country_id, $url) { if (category::where('id', '!=', $id)->where('country_id', $country_id)->where('url', $url)->count() == 0) { return true; } return false; }
public function __selectCategoryRelatedCountry($country) { if (count($country) > 0) { return category::select('id', 'name')->where('country_id', $country[0]->id)->get(); } else { return []; } }