How can I display the validation message in the view that is being redirected in Laravel ?

Here is my controller

public function registeruser() { $firstname = Input::get('firstname'); $lastname = Input::get('lastname'); $data = Input::except(array('_token')) ; $rule = array( 'firstname' => 'required', 'lastname' => 'required', ) ; $validator = Validator::make($data,$rule); if ($validator->fails()) { $messages = $validator->messages(); return Redirect::to('/')->with('message', 'Register Failed'); } else { DB::insert('insert into user (firstname, lastname) values (?, ?)', array($firstname, $lastname)); return Redirect::to('/')->with('message', 'Register Success'); } }


In Progress 01-11-2019 Awais 987

Please briefly explain why you feel this question should be reported .

Answers (0)

Leave An Answer

app logo

Download Our App!

Enjoy all the features. Browse jobs, articles, questions, scholarships and many more! in just one App