programService = $programService; $this->costCalculatorService = $costCalculatorService; $headerMenus = getAllHeaderMenusWithChildren(); $footerMenus = getAllFooterMenusWithChildren(); $tests = Test::where('status', 1)->where('parent_id', null)->get(); $countries = Country::where('status', 1)->where('parent_id', null)->get(); $interviews = Service::where('status', 1)->where('parent_id', null)->get(); $services = Service::where('status', 1)->where('parent_id', null)->get(); $data['previousEvents'] = previousEvents(limit: null, order: 'asc'); $data['upcomingEvents'] = upcomingEvents(limit: null, order: 'asc'); $this->path = config('app.client'); view()->share([ 'headerMenus' => $headerMenus, 'footerMenus' => $footerMenus, 'tests' => $tests, 'countries' => $countries, 'services' => $services, 'interviews' => $interviews, 'previousEvents' => $data['previousEvents'], 'upcomingEvents' => $data['upcomingEvents'], ]); } public function home() { $data['sliders'] = getSliders(limit: null, order: 'asc'); $data['counters'] = getCounters(limit: null, order: 'asc'); $data['successGalleries'] = getGalleriesByCategory(limit: 3, order: 'asc', category: 'voice-of-success'); $data['destinations'] = getDestinations(limit: null, order: 'asc'); $data['services'] = getServices(limit: null, order: 'asc'); $data['classes'] = getClasses(limit: null, order: 'asc'); $data['institutions'] = getInstitutions(limit: null, order: 'asc'); $data['faqs'] = getFAQs(limit: null, order: 'desc'); $data['testimonials'] = getTestimonials(limit: null, order: 'desc'); $data['blogs'] = getBlogs(limit: 4, order: 'desc'); $data['partners'] = getPartners(); $data['gallaries'] = getGalleries(limit: 6, order: 'asc'); $data['achievementGalleries'] = getGalleriesByCategory(limit: null, order: 'asc', category: 'achievement'); $data['visaGalleries'] = getGalleriesByCategory(limit: null, order: 'asc', category: 'visa-success'); $page = $data['page'] = getPageWithChildrenBySlug(parent: null, slug: '/', limit: null, order: 'asc'); if (!$page) { return view("client.$this->path.errors.404"); } $path = "client.$this->path.pages.$page->template"; if (!View::exists($path)) { return view("client.$this->path.errors.404"); } return view($path, $data); } public function blogSingle($alias) { $blog = $data["page"] = Blog::where('status', 1) ->where('slug', $alias)->first(); $data['blogs'] = getBlogs(limit: null, order: 'desc'); if (!$blog) { return view("client.$this->path.errors.404"); } $data['categories'] = getBlogCategories(limit: null, order: 'desc'); $data['recentBlogs'] = Blog::where('status', 1) ->where('id', '!=', $blog->id) ->inRandomOrder() ->orderBy('created_at', 'desc') ->take(5)->get(); $blog->increment('views'); return view("client.$this->path.pages.blog-single-template", $data); } public function serviceSingle($alias) { $service = $data["page"] = Service::where('status', 1) ->where('slug', $alias) ->with('children', function ($query) { $query->where('status', 1) ->orderBy('order'); }) ->first(); if (!$service) { return view("client.$this->path.errors.404"); } $data['recentServices'] = Service::where('status', 1) ->where('parent_id', null) ->orderBy('created_at', 'desc') ->inRandomOrder() ->take(5)->get(); $data['serviceFAQs'] = getFAQsByCategory(limit: null, order: 'desc', category: $service->slug); return view("client.$this->path.pages.test-single-template", $data); } public function careerSingle($id) { $data['career'] = Career::findorFail($id); return view("client.$this->path.pages.career-detail-template", $data); } public function testSingle($alias) { $testPreparations = $data["page"] = Test::where('status', 1) ->where('slug', $alias) ->with('children', function ($query) { $query->where('status', 1) ->orderBy('order'); }) ->first(); if (!$testPreparations) { return view("client.$this->path.errors.404"); } return view("client.$this->path.pages.test-single-template", $data); } public function countrySingle($alias) { $country = $data["page"] = Country::where('status', 1) ->where('slug', $alias) ->first(); if (!$country) { return view("client.$this->path.errors.404"); } // $data['countryFAQs'] = getFAQsByCategory(limit: null, order: 'desc', category: $country->slug); // $data['countryInstitutions'] = $country->institutions; // $data['recentCountries'] = Country::where('status', 1) // ->where('id', '!=', $country->id) // ->inRandomOrder() // ->orderBy('created_at', 'desc') // ->take(5)->get(); return view("client.$this->path.pages.study-destination-template", $data); } public function loadPage(?string $parent = null, ?string $slug = null) { if ($slug === null) { $slug = $parent; $parent = null; } $page = getPageWithChildrenBySlug(parent: $parent, slug: $slug, limit: null, order: 'asc'); $teams = getTeams(limit: null, order: 'asc'); $blogs = getBlogs(limit: null, order: 'asc'); $galleriesCSR = getPageWithChildrenBySlug(parent: $parent, slug: 'gallery', limit: null, order: 'asc'); $careers = getCareers(limit: null, order: 'asc'); if (!$page) { return view('client.raffles.errors.404'); } $path = "client.$this->path.pages.$page->template"; if (!View::exists($path)) { return view('client.raffles.errors.404'); } return view($path, ['page' => $page, 'teams' => $teams, 'blogs' => $blogs, 'galleriesCSR' => $galleriesCSR], ['careers' => $careers]); } public function fallback() { return view("client.$this->path.errors.404"); } public function coursefinder(Request $request) { $data['page'] = Page::where(['slug' => 'course-finder', 'status' => 1])->first(); $data['title'] = 'Program List'; $data['programs'] = $this->programService->findAll($request); $data['countryOptions'] = Country::where('status', 1)->where('parent_id', null)->pluck('title', 'id'); $data['institutionOptions'] = Institution::query() ->when($request->filled('country_id'), function ($query) use ($request) { $query->where('country_id', $request->country_id); }) ->pluck('title', 'id'); $data['programLevelOptions'] = ProgramLevel::where('status', 1)->pluck('title', 'id'); $data['intakeOptions'] = Program::INTAKE; $data['coopOptions'] = Coop::where('status', 1)->pluck('title', 'id'); $data['testOptions'] = Test::where('status', 1)->where('parent_id', null)->pluck('title', 'id'); $data['statusOptions'] = config('constants.page_status_options'); return view("client.$this->path.pages.coursefinder-template", $data); } public function coursefinderSingle($id) { $course = $data["page"] = Program::where('status', 1) ->where('id', $id) ->first(); $data['intakeOptions'] = Program::INTAKE; if (!$course) { return view("client.$this->path.errors.404"); } return view("client.raffles.pages.coursefinder-single", $data); } public function resources() { $data['countries'] = Country::where('status', 1)->where('parent_id', null)->get(); $data['tests'] = Test::where('status', 1)->where('parent_id', null)->get(); $data['interviews'] = Service::where('status', 1)->where('parent_id', null)->get(); return view("client.raffles.pages.resources-template", $data); } public function costCalculator(Request $request) { $data['programs'] = $this->programService->findAll($request); $data['programss'] = Program::where('status', 1)->pluck('title', 'id'); $data['countryOptions'] = Country::where('status', 1)->where('parent_id', null)->pluck('title', 'id'); $data['programLevelOptions'] = ProgramLevel::where('status', 1)->pluck('title', 'id'); $data['intakeOptions'] = Program::INTAKE; $data['coopOptions'] = Coop::where('status', 1)->pluck('title', 'id'); $data['testOptions'] = Test::where('status', 1)->where('parent_id', null)->pluck('title', 'id'); $data['livingStatusOptions'] = StayType::where('status', 1)->pluck('title', 'id'); return view("client.raffles.pages.cost-calculator", $data); } public function getCost(Request $request) { $costs = $this->costCalculatorService->findAll($request); if ($costs->isEmpty()) { return view("client.raffles.errors.404"); } $id = $costs->last()->id; $cost = CostCalculator::with([ 'stayTypeLiving', 'stayTypeAccomodation', 'stayTypeOnetime', 'stayTypeService' ])->find($id); if (!$cost) { return view("client.raffles.errors.404"); } $program = Program::find($request->program_id); if (!$program) { return view("client.raffles.errors.404"); } $getBreakdown = function ($stayTypeTitle) use ($cost) { $living = optional($cost->stayTypeLiving->firstWhere('title', $stayTypeTitle))->pivot; $accomodation = optional($cost->stayTypeAccomodation->firstWhere('title', $stayTypeTitle))->pivot; $onetime = optional($cost->stayTypeOnetime->firstWhere('title', $stayTypeTitle))->pivot; $service = optional($cost->stayTypeService->firstWhere('title', $stayTypeTitle))->pivot; return [ 'living' => [ 'monthly' => $living->monthly ?? 0, 'yearly' => $living->yearly ?? 0, ], 'accomodation' => [ 'monthly' => $accomodation->monthly ?? 0, 'yearly' => $accomodation->yearly ?? 0, ], 'onetime' => [ 'visa' => $onetime->visa ?? 0, 'biometrics' => $onetime->biometrics ?? 0, 'sevis' => $onetime->sevis ?? 0, 'application' => $onetime->application ?? 0, 'total' => ($onetime->visa ?? 0) + ($onetime->biometrics ?? 0) + ($onetime->sevis ?? 0) + ($onetime->application ?? 0), ], 'service' => [ 'flight_ticket' => $service->flight_ticket ?? 0, 'insurance' => $service->insurance ?? 0, 'extra' => $service->extra ?? 0, 'total' => ($service->flight_ticket ?? 0) + ($service->insurance ?? 0) + ($service->extra ?? 0), ] ]; }; $data = [ 'costs' => $costs, 'fee' => $program, 'title' => 'View Cost Calculation', 'cost' => $cost, 'breakdowns' => [ 'alone' => $getBreakdown('Alone'), 'with_spouse' => $getBreakdown('With Spouse'), 'with_spouse_and_child' => $getBreakdown('With Spouse and Child'), ], ]; return view('client.raffles.pages.cost-result', $data); } public function thankyouPage(Request $r) { $data = new \stdClass(); $data->title = "Thank You"; return view("client.raffles.pages.thankyou", compact('data')); } }