예제 #1
0
 /**
  * display contact form
  */
 public function sendComplaints(Request $request)
 {
     $data = $request->all();
     $rules = array('name' => 'required', 'email' => 'required', 'subject' => 'required', 'message' => 'required');
     $validator = Validator::make($data, $rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     $contact = Contact::first();
     if ($contact) {
         $formdata = array('name' => $data['name'], 'email' => $data['email'], 'subject' => $data['subject'], 'text' => $data['message'], 'receiver' => $contact->email);
         $x = Mail::send('contact.contactus.show', $formdata, function ($email) use($formdata) {
             $email->from($formdata['email'], $formdata['name']);
             $email->to($formdata['receiver'])->subject($formdata['subject']);
         });
         dd($x);
     }
     return view('contact.contactus.success');
 }