0
In Lumen version 5.2 the following validation in the Controller is working:
$this->validate($request, [
'nome' => 'required',
'email' => 'required|email',
'cpf' => 'required',
]);
Iofc the following View:
@if (count($errors) > 0) {
<div>
<ul>
@foreach($errors->all() as $error){
echo("<li>". $error . "</li>");
}
@endforeach
</ul>
</div>
@endif
It turns out that in version 5.5 of Lumen is not working.
The following error is displayed:1/1) Errorexception Undefined variable: errors in cadasPeople.php (line 8) at Application->Laravel Lumen Concerns{closure}(8, 'Undefined variable: errors', 'C: wamp64 www blog Resources views cadasPessoas.Ph p', 8, array('__path' => 'C: wamp64 www blog Resources views/cadastroPessoas.php ', '__data' => array('__env' => Object(Factory), 'app' => Object(Application)), 'obLevel' => 1, '__env' => Object(Factory), 'app' => Object(Application))) in cadastre('C: wamp64 www blog Resources views cadastroPe ssoas.php
Is there an error? Enabled DEBUG?
– Guilherme Nascimento
The following error appears:1/1) Errorexception Undefined variable: errors in cadasPeople.php (line 8) at Application->Laravel Lumen Concerns{closure}(8, 'Undefined variable: errors', 'C: wamp64 www blog Resources views cadasPessoas.php', 8, array('__path' => 'C: wamp64 www blog Resources views/cadastroPessoas.php', '__data' => array('__env' => Object(Factory), 'app' => Object(Application)), 'obLevel' => 1, '__env' => Object(Factory), 'app' => Object(Application)) in cadastre('C: wamp64 www blog Resources views cadastre
– Fernando I. Kobayashi
@Guillhermenascimento
– Fernando I. Kobayashi
@Virgilionovic doesn’t see how it can be duplicated, because the error is not with the validation, but rather a syntax error and another reason is that Lumen and Laravel despite sharing the same ecosystem, they have the 'application' layer a little different, aiming that the intention of the Lumen is to be much more light that Laravel, so its settings may vary, such as the configuration of middleware, I believe the author forgot to add
Illuminate\View\Middleware\ShareErrorsFromSession
(required to make the variable available globally$errors
).– Guilherme Nascimento
@Fernandoi.Kobayashi reply edited, see https://answall.com/a/246481/3635, read the part I wrote "Important note about $errors in Laravel/Lumen views"
– Guilherme Nascimento
@Guilhermenascimento in the part Laravel and Lumen there are enough controversies regarding performance and functionalities, I will withdraw the vote of duplicate, because, who asked the question has now put the error message of variable not defined.
– novic
@Virgilionovic I understand, but I just wanted to say that regardless of whether or not I informed the error message, there was no evidence of duplicity, the only indication before the AP informed the error message was that there were possible syntax errors regarding the use of "Blade" (which may or may not cause the failure, summarizing it would be more necessary to vote as "typo"). Thank you ;)
– Guilherme Nascimento
@Guilhermenascimento to me came at first that there was a problem at the time of calling the validation and the associated answer of duplicity had the explanation that apparently he needed. Thank you !
– novic
@Guilhermenascimento , in relation to note en.stackoverflow.com/a/246481/3635, was like this in version 5.2 of Lumen. I thank you for the help you are giving me,
– Fernando I. Kobayashi