I'm trying to pass an error msg through a middleware. If you use $ errors-> all () the error appears, but how do you use $ errors-> has ('active')? Or would it be easier to pass this middleware message? 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>