path = config('app.client_path'); $headerMenuItems = Menuitems::where(['parent_menu' => 0, "status" => 1, "menulocations_id" => 1])->with('children')->orderBy('display_order')->get(); // dd($headerMenuItems->toArray()); $footerMenuItems = Menuitems::where(['parent_menu' => 0, "status" => 1, "menulocations_id" => 2])->with('children')->orderBy('display_order')->get(); // dd($footerMenuItems->toArray()); $recentNews = News::where('status', 1)->inRandomOrder()->limit(4)->get(); View::share( [ 'headerMenuItems' => $headerMenuItems, 'footerMenuItems' => $footerMenuItems, 'recentNews' => $recentNews, ] ); } public function home() { $data['featuredNews'] = News::where('featured_news', "True")->where('status', 1)->first(); $data['provinces'] = Provinces::with('provinceNews')->limit(5)->get(); $data['categories'] = Newscategories::with('news')->get(); $data['interviews'] = Newscategories::with('interviewNews')->get(); $data['politics'] = Newscategories::with('politicNews')->get(); // $data['economics'] = Newscategories::with('news')->inRandomOrder()->get(); $data['economics'] = Economies::with('news') ->orderBy('display_order') ->where('status', 1) ->get(); $data['sports'] = Newscategories::with('sportNews')->get(); $data['cultural'] = Newscategories::with('culturalNews')->get(); $data['technology'] = Newscategories::with('technologyNews')->get(); $data['entertainment'] = Newscategories::with('entertainmentNews')->get(); $data['branches'] = Newscategories::with('branchesNews')->get(); $data['videos'] = Videos::where('status', 1)->orderBy('display_order')->get(); $data['horoscope'] = Horoscopes::where('status', 1)->orderBy('display_order')->get(); // dd($data['videos']); $data['internationalNews'] = News_type::with('news')->get(); // dd($data['internationalNews']->toArray()); // dd($data['internationalNews']); return view($this->path . '.home', $data); } public function single($alias) { $categoryId = Newscategories::where('alias', $alias)->pluck('category_id')->first(); $categoryTitle = Newscategories::where('alias', $alias)->pluck('nepali_title')->first(); $data = News::where('newscategories_id', $categoryId)->where('status', 1)->orderBy('display_order')->paginate(9); return view($this->path . '.single', compact('data', 'categoryTitle')); } public function newsDetail($alias) { $news = News::where('alias', $alias)->where('status', 1)->first(); $recentNews = News::where('status', 1)->where('news_id', '!=', $news->news_id)->inRandomOrder()->limit(12)->latest()->get(); return view($this->path . '.news-detail', compact('news', 'recentNews')); } public function showHororscope() { $rashifal = Horoscopes::where('status', 1)->orderBy('display_order')->limit(12)->get(); return view($this->path . '.rashifal', compact('rashifal')); } public function showInternational($alias) { $categoryTitle = News_type::where('alias', $alias)->value('title_nepali'); $data = News::where('news_type_id', 1) ->where('status', 1)->orderBy('display_order')->paginate(9); return view($this->path . '.single', compact('data', 'categoryTitle')); } public function showVideos() { dd('test'); } public function showAboutus($alias) { $data['aboutus'] = Articles::where('alias', $alias)->where('status', 1)->first(); $data['teams'] = Teams::where('status', 1)->orderBy('display_order')->get(); return view($this->path . '.about-us', $data); } public function showArtilce($alias) { $data['article'] = Articles::with('childrens')->where('alias', $alias)->where('status', 1)->first(); return view($this->path . '.article', $data); } public function showContact() { return view($this->path . '.contact'); } public function sendEmail(Request $request) { if ($request->input('accepted') == 'on') { $requestData = $request->except(['_token', 'accepted']); $validator = Validator::make($requestData, [ 'title' => 'required|string|max:255', 'email' => 'required|email', 'phone_number' => 'required|regex:/\d{10}/', 'secondary_number' => 'nullable|regex:/\d{10}/', 'message' => 'required|string', ]); if ($validator->fails()) { return redirect()->back()->withErrors($validator)->withInput(); } $validated = $validator->validated(); try { Mail::to(SITEVARS->email)->send(new SendEmail($validated)); return response()->json(['success' => 'Email sent successfully']); } catch (\Exception $e) { return response()->json(['error' => 'Failed to send email'], 500); } } else { return response()->json(['error' => 'Acceptance checkbox is required'], 400); } } public function showProvinces($id) { $categoryTitle = Provinces::where('province_id', $id)->pluck('province_nepali_name')->first(); $data = News::where('provinces_id',$id)->where('status',1)->orderBy('display_order')->paginate(9); return view($this->path . '.single', compact('data','categoryTitle')); } } // public function single($alias) // { // $categoryId = Newscategories::where('alias', $alias)->pluck('category_id')->first(); // $categoryTitle = Newscategories::where('alias', $alias)->pluck('nepali_title')->first(); // $data = News::where('newscategories_id', $categoryId)->where('status', 1)->orderBy('display_order')->paginate(9); // return view($this->path . '.single', compact('data', 'categoryTitle')); // }