app/Http/Controllers/PesanController.php
/**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
Store a newly created resource in storage.
Store a newly created resource in storage .
public function store(Request $request)
    {
        $this->validate($request, [
            'name' => 'required|max:30',
            'email' => 'email|required',
            'subject' => 'required',
            'message' => 'required'
        ]);
        try {
            $pesan = Pesan::create([
                'name' => $request->name,
                'email' => $request->email,
                'subject' => $request->subject,
                'message' => $request->message
            ]);
            Alert::success('Pesan Anda Terkirim');
            return redirect()->back();
        } catch (Exception $e) {
            return redirect()->back()->with(['error' => $e->getMessage()]);
        }
    }
public function store ( Request $ request ) { $ this -> validate ( $ request , [ 'name' => 'required|max:30' , 'email' => 'email|required' , 'subject' => 'required' , 'message' => 'required' ] ) ; try { $ pesan = Pesan :: create ( [ 'name' => $ request -> name , 'email' => $ request -> email , 'subject' => $ request -> subject , 'message' => $ request -> message ] ) ; Alert :: success ( 'Pesan Anda Terkirim' ) ; return redirect ( ) -> back ( ) ; } catch ( Exception $ e ) { return redirect ( ) -> back ( ) -> with ( [ 'error' => $ e -> getMessage ( ) ] ) ; } }
Store a newly created resource in storage.
Store a newly created resource in storage .