Guest User

controller

a guest
Sep 24th, 2020
15
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. namespace App\Http\Controllers;
  4. use Illuminate\Http\Request;
  5. use Illuminate\Support\Facades\Mail;
  6. use App\Contact;
  7.  
  8.  
  9. class ContactUsFormController extends Controller {
  10.  
  11.     // Create Contact Form
  12.     public function createForm(Request $request) {
  13.        
  14.       return view('pages.contact');
  15.     }
  16.  
  17.     // Store Contact Form data
  18.     public function ContactUsForm(Request $request) {
  19.  
  20.         //  Store data in database
  21.         Contact::create($request->all());
  22.        
  23.  
  24.         Mail::send('mail', array(
  25.             'name' => $request->get('name'),
  26.             'email' => $request->get('email'),
  27.             'subject' => $request->get('subject'),
  28.             'user_query' => $request->get('message'),
  29.             'gpdr' => $request->get('gpdr'),
  30.         ), function($message) use ($request){
  31.             $message->from($request->email);
  32.             $message->to('email@example.com', 'Mipso.pl')->subject($request->get('subject') . ' [email@example.com]' );
  33.         });
  34.      
  35.  
  36.         return back()->with('success', 'Dziękujemy za wiadomość, wkrótce odpowiemy.');
  37.     }
  38.  
  39. }
RAW Paste Data