laravel - Error handling from external request class -
in login system i'm creating in laravel (version 5.2), registration request passed on registrationrequest
class, contains validation logic this:
public function rules() { return [ "username" => "required|min:3|unique:users", "password" => "required|min:6|confirmed", "email" => "required|confirmed|email|unique:users", ]; }
which passed on postregistration
function:
public function postregistration(registrationrequest $request) { $this->user->username = $request->input('username'); $this->user->mail = $request->input('email'); $this->user->password = password_hash($request->input('password'), password_default); $this->user->save(); $this->auth->login($this->user); return redirect('/dashboard'); }
all kind of basic stuff, problem have have no idea how show error when username example 2 characters long.
i know normally, i'd
return redirect('/registration)->withinput()->witherrors(["errorhere" => "value"]);
but since validation rules external, have no clue how pass view.
i searched forums , docs, couldn't find clear on it.
is there way show these errors, preferably withinput()
method?
thanks.
as can see docs laravel:
@if (count($errors) > 0) <div class="alert alert-danger"> <ul> @foreach ($errors->all() $error) <li>{{ $error }}</li> @endforeach </ul> </div> @endif
edit: didn't notice author answered question until refreshed page.
Comments
Post a Comment