“Regras de Laravel” Respostas de código

Validação por e -mail em Laravel

'email' => 'required|email|unique:users,email',
//@sujay
$uj@y

PHP Artisan Make: Solicitação

php artisan make:request User\CreateUserRequest 
Encouraging Echidna

Se algum erro na lâmina Laravel

 @if ($errors->any())
     @foreach ($errors->all() as $error)
         <div>{{$error}}</div>
     @endforeach
 @endif
Zamir

erros de validação de retorno de Laravel

@if($errors->any())
   @foreach ($errors->all() as $error)
      <div>{{ $error }}</div>
  @endforeach
@endif
Xfantasia

Regras de Laravel

public function store(Request $request) {
    $this->validate($request, [
        'name' => 'required|string',
        'body' => 'required|string',
        'publish_at' => 'required|date_format:Y-m-d H:i:s'
    ], [
      'name.required' => 'A article name is required',
      'body.required'  => 'A article body is required',
      'publish_at.date_format' => 'The publish at date is not in the correct format.'
    ]);
 
    // The request validated and this code will get run
    ...
}
Itchy Ibis

Regras de Laravel

public function store(Request $request) {
    $this->validate($request, [
        'name' => 'required|string',
        'body' => 'required|string',
        'publish_at' => 'required|date_format:Y-m-d H:i:s'
    ], [
      'name.required' => 'A article name is required',
      'body.required'  => 'A article body is required',
      'publish_at.date_format' => 'The publish at date is not in the correct format.'
    ]);
 
    // The request validated and this code will get run
    ...
}
Itchy Ibis

Respostas semelhantes a “Regras de Laravel”

Procure respostas de código populares por idioma

Procurar outros idiomas de código