path = config('app.client_path'); $headerMenu = Menulocations::where('alias', 'header-menu')->first(); $headerMenuItems = Menuitems::where('menulocations_id', $headerMenu->menulocation_id)->where('status', '<>', -1)->where('parent_menu', 0)->with('children')->orderBy('display_order', 'asc')->get(); $footerMenu = Menulocations::where('alias', 'footer-menu')->first(); $footerMenuItems = Menuitems::where('menulocations_id', $footerMenu->menulocation_id)->where('status', '<>', -1)->where('parent_menu', 0)->with('children')->orderBy('display_order', 'asc')->get(); $popularNews = News::inRandomOrder()->inRandomOrder()->take(3)->get(); View::share([ 'headerMenuItems' => $headerMenuItems, 'footerMenuItems' => $footerMenuItems, 'popularNews' => $popularNews ]); } public function home() { $data["sliders"] = Sliders::where('status', 1)->latest()->get(); $data["franchises"] = Franchises::latest()->take(4)->get(); $data["testimonials"] = Testimonials::where('status', 1)->latest()->get(); $data['services'] = Services::latest()->where('parent_service', null) ->orWhere('parent_service', 0) ->where('status', 1) ->inRandomOrder() ->get(); $data['partners'] = Partners::latest()->get(); $data["news"] = News::latest()->take(6)->get(); $data['whyChooseUs'] = Companyarticles::where('status', 1) ->where('alias', 'why-choose-us') ->with('children') ->first(); $data['homecontent'] = Companyarticles::where('status', 1)->where('alias', 'global-supplier')->latest()->first(); $data['whychoose'] = Companyarticles::where('status', 1) ->where('alias', 'why-choose-us') ->with('children') ->first(); return view("client.$this->path.welcome", $data); } public function showArticle($alias) { $whyChooseUs = Companyarticles::where('status', 1) ->where('alias', 'why-choose-us') ->with('children') ->first(); $article = Companyarticles::where('status', 1) ->where('parent_article', 0) ->where('alias', $alias) ->with('children') ->first(); $teams = Teams::where('status', 1)->latest()->get(); return view("client.$this->path.article-single", compact('teams', 'alias', 'article', 'whyChooseUs')); } public function teams() { $teams = Teams::where('status', 1)->orderBy('display_order')->get(); return view("client.$this->path.teams", compact('teams')); } public function testimonials() { $testimonials = Testimonials::where('status', 1)->latest()->get(); return view("client.$this->path.testimonials", compact('testimonials')); } public function franchise() { $franchises = Franchises::latest()->get(); return view("client.$this->path.franchise", compact('franchises')); } public function news() { $news = News::where('status', 1) ->latest() ->paginate(3); return view("client.$this->path.news", compact('news')); } public function showNews($alias) { $news = News::where('alias', $alias)->latest()->first(); return view("client.$this->path.news-single", compact('news')); } public function showFranchise($alias) { $content = Franchises::where('alias', $alias)->first(); return view('client.topCargo.franchise-single', compact('content')); } public function showService($alias) { $serviceLists = Services::where('status', 1) ->whereNull('parent_service') ->orWhere('parent_service', 0) ->select(['title', 'alias']) ->get(); $service = Services::where('alias', $alias)->where('status', '<>', -1)->with('children', fn ($query) => $query->latest())->first(); return view('client.topCargo.service-single', compact('service', 'serviceLists')); } public function contact() { return view("client.$this->path.contact"); } public function quote() { return view("client.$this->path.quote"); } public function tracking() { return view("client.$this->path.tracking"); } public function sendEmail(Request $request) { $identifier = $request->input('identifier'); if ($identifier == "contact") { $validated = $request->validate([ 'name' => 'required|min:3|max:255', 'email' => 'required|email', 'message' => 'required|min:10', 'phone' => 'required|string|regex:/^98\d{8}$/', ]); $sent = Mail::to(SITEVARS->email)->send(new ContactMail($validated)); if ($sent) { return response()->json(['success' => 'Email sent successfully']); } else { return response()->json(['error' => 'Failed to send email'], 500); } } else { $validated = $request->validate([ 'firstname' => 'required|string', 'lastname' => 'required|string', 'email' => 'required|email', 'citydeparture' => 'required|string', 'DeliverCity' => 'required|string', 'weight' => 'required|numeric', 'specialinfo' => 'nullable|string', 'freightType' => 'required|array', 'freightType.*' => 'required|string', ]); $sent = Mail::to(SITEVARS->email)->send(new QuoteMail($validated)); if ($sent) { return response()->json(['success' => 'Email sent successfully']); } else { return response()->json(['error' => 'Failed to send email'], 500); } } } }