简体   繁体   中英

How to redirect to home page After Submitting the form in Laravel

This Is Form Controller How can I redirect to Home Page after submission of form? or redirect to any url?

public function sendEmail(Request $request){
            $this->validate($request, [
                            'fullname' => 'required',
                            'phonenumb' => 'required',
                            'mail' => 'required',
                   ]);
    
            Mail::send('email', [
                    'fullname' => $request->get('fullname'),
                    'phonenumb' => $request->get('phonenumb'),
                    'mail' => $request->get('mail') ],
                    function ($message) {
                            $message->from('example@domain.com');
                            $message->to('example@domain.com', 'Subject')
                                    ->subject('New candidate for Job ');
            });
    
            return back()->with('success', 'Thanks for contacting me, I will get back to you soon!');
    
        }
    }

您可以使用路线:

return redirect()->route('profile');

Using the redirect helper

redirect to route

return redirect()->route('home');

redirect to different url

return redirect('https://www.google.com/');

more about redirects in laravel

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM