Server : Apache System : Linux host44.registrar-servers.com 4.18.0-513.18.1.lve.2.el8.x86_64 #1 SMP Sat Mar 30 15:36:11 UTC 2024 x86_64 User : vapecompany ( 2719) PHP Version : 7.4.33 Disable Function : NONE Directory : /proc/thread-self/root/home/vapecompany/demo.vapecompany.com.bd/app/Http/Controllers/Frontend/ |
Upload File : |
<?php namespace App\Http\Controllers\Frontend; use App\Http\Controllers\Controller; use Illuminate\Http\Request; use DB; use App\Models\Contact_form; class PageController extends Controller { function __construct(){ $this->middleware('guest:web'); } public function contact() { return view('frontend.pages.contact'); } function contact_form(Request $request){ $validator = \Validator::make($request->all(), [ 'name' => 'required|max:150', 'email' => 'required|max:150', ]); if ($validator->fails()) { return response()->json(['errors'=>$validator->errors()->all()]); }else{ try { DB::beginTransaction(); $category = new Contact_form; $category->name = $request->name; $category->email = $request->email; $category->phone_number = $request->phone; $category->message = $request->message; // $category->created_by = auth('admin')->user()->id; $category->save(); DB::commit(); } catch (\PDOException $e) { // Woopsy DB::rollBack(); return response()->json(['errors'=>$e]); } } return redirect()->back(); } }