0
I am trying to pass an error msg through a middleware. If I use $errors->all() the error appears, but how do I use $errors->has('active')? Or if you could just pass this message from middleware more easily? Another question is how to customize the email error for example?
Middleware:
namespace Ecommerce\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\Auth;
class CheckStatus
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if(Auth::user()->active != 'yes') {
Auth::logout();
return redirect('/login')->withErrors('Usuário precisa de aprovação');
}
return $next($request);
}
}
View Login:
<div class="form-group ">
<div class="col-xs-12">
<input id="email" type="email" class="form-control" name="email" value="{{ old('email') }}" required autofocus placeholder="Email">
</div>
@if ($errors->has('email'))
<span class="help-block">
<strong>{{ $errors->first('email') }}</strong>
</span>
@endif
@if ($errors->has('active'))
<span class="help-block">
<strong>{{ $errors->first('active') }}</strong>
</span>
@endif
</div>
It had gone that way but I must have done something wrong. But it worked now. Thank you
– Marcelo