/** * Create a new Enquiry. * * @param Request $request * @return Response */ public function store(Request $request) { $rules = array('user_id' => 'required|numeric', 'services' => 'required|numeric', 'subjectarea' => 'required|numeric'); $validator = Validator::make($request->all(), $rules); if ($validator->fails()) { return redirect('/ncf')->withErrors($validator)->withInput(); } else { // store $enquiry = new Enquiry(); $enquiry->userid()->user_id = $request->user_id; $enquiry->service_id = $request->services; $enquiry->sa_id = $request->subjectarea; $enquiry->save(); // redirect return redirect('/ncf'); } }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { // $validator = \Validator::make($request->all(), ['name' => 'required', 'subject' => 'required', 'phone' => 'required', 'g-recaptcha-response' => 'required']); if ($validator->fails()) { return response()->json(array('status' => 500, 'monolog' => array('title' => 'errors', 'message' => $validator->errors()))); } $enquiry = new Enquiry(); $enquiry->property_id = $request->property_id; // $enquiry->customer_id = $request->customer_id; $enquiry->subject = $request->subject; $enquiry->content = $request->content; if ($request->name) { $name = explode(' ', $request->name); $enquiry->firstname = $name[0]; if (count($name) > 1) { $enquiry->lastname = $name[1]; } } else { $enquiry->firstname = $request->firstname; $enquiry->lastname = $request->lastname; } $enquiry->phone = $request->phone; $enquiry->email = $request->email; $enquiry->save(); $this->email($enquiry); return response()->json(array('status' => 200, 'monolog' => array('title' => 'success', 'message' => 'object has been saved'))); }
public function postEnquiry(Requests\EnquiryAddRequest $request) { $enquiry = new Enquiry(); $enquiry->email = $request->email; $enquiry->name = $request->name; $enquiry->enquiry = $request->enquiry; $enquiry->save(); $email = $enquiry->email; Mail::send('emails.messageThanks', ['name' => $enquiry->name], function ($message) use($email) { $message->from(Config::get('app.noreplyEmail'), Config::get('app.noreplyEmailName')); $message->to($email)->subject(Config::get('app.companyName') . ' - Message received'); }); Mail::send('emails.messageNotification', ['name' => $enquiry->name, 'email' => $enquiry->email, 'enquiry' => $enquiry->enquiry, 'id' => $enquiry->id], function ($message) { $message->from(Config::get('app.adminEmail'), Config::get('app.noreplyEmailName')); $message->to(Config::get('app.adminEmail'), Config::get('app.adminName'))->subject(Config::get('app.companyName') . ' - Message notification'); }); return Redirect::to('contact-us')->with('message', 'Thanks. Your message has been sent. You\'ll be hearing form us shortly')->with('type', 'success')->withInput(); }