get(); // dd( $result['data']); $cat['category']=Category::all(); $pro['product']=Product::all(); return view('front.index' , compact('cat', 'pro', 'result')); } public function category($id) { // this for navbar $cat['category']=Category::all(); $pro['product']=Product::all(); //this for category page $procat['data'] = DB::table('products') ->join('categories', 'categories.category_slug', '=', 'products.category_id')// joining the contacts table , where user_id and contact_user_id are same ->where('products.category_id', '=' , $id) ->select('products.*', 'categories.category_name') ->get(); $result = Category::where('category_slug' , '=' , $id)->first(); return view('front.category' , compact('cat', 'procat' , 'pro' ,'result')); } public function product($id) { // this for navbar $cat['category']=Category::all(); $result = Product::where('product_slug' , '=' , $id)->first(); return view('front.product' , compact('cat' , 'result')); } public function aboutus() { $cat['category']=Category::all(); return view('front.aboutus' , compact('cat')); } public function contactus() { $cat['category']=Category::all(); return view('front.contactus' , compact('cat')); } // public function submitContactForm(Request $request) // { // $validator = Validator::make($request->all(), [ // 'name' => 'required|string', // 'email' => 'required|email', // 'phone' => 'required', // 'message' => 'required|string', // 'g-recaptcha-response' => 'required|captcha', // ]); // if ($validator->fails()) // { // return redirect()->back()->withErrors($validator)->withInput(); // } // else // { // $recaptcha = new ReCaptcha(config('app.recaptcha_secret_key')); // $response = $recaptcha->verify($request->input('g-recaptcha-response'), $request->ip()); // if ($response->isSuccess()) { // $data = $request->only('name', 'email', 'phone' , 'message'); // Mail::to('nimesh.empieretech15@gmail.com')->send(new ContactMail($data)); // return redirect()->back()->with('message', 'Message sent successfully!'); // } else { // return redirect()->back()->withErrors(['message' => 'reCAPTCHA verification failed. Please try again.']); // // Log or handle the error codes as needed // } // } // } public function submitContactForm(Request $request) { $validator = Validator::make($request->all(), [ 'name' => 'required|string', 'email' => 'required|email', 'phone' => 'required', 'message' => 'required|string', ]); if ($validator->fails()) { return redirect()->back() ->withErrors($validator) ->withInput(); } try { $html = "

New Contact Inquiry

Name: {$request->name}

Email: {$request->email}

Phone: {$request->phone}

Message:
{$request->message}

"; $payload = [ "mails" => [ [ "email" => "nimesh.empieretech15@gmail.com", "subject" => "New Contact Form Inquiry", "html" => $html ] ] ]; $response = Http::withHeaders([ 'Content-Type' => 'application/json', 'Accept' => 'application/json', ])->post(env('MAIL_API_URL'), $payload); if ($response->successful()) { return back()->with( 'message', 'Mail sent successfully ✅' ); } return back()->with( 'error', 'API Mail Failed' ); } catch (\Throwable $e) { return back()->with( 'error', $e->getMessage() ); } } public function termscondition() { $cat['category']=Category::all(); return view('front.terms&condition' , compact('cat')); } public function privacypolicy() { $cat['category']=Category::all(); return view('front.privacypolicy' , compact('cat')); } }