Answers for "laravel if there are errors in request"

PHP
1

laravel return validation errors

@if($errors->any())
   @foreach ($errors->all() as $error)
      <div>{{ $error }}</div>
  @endforeach
@endif
Posted by: Guest on January-29-2021
0

laravel return validation errors ajax

public function testAjax(Request $request)
  {
    $name = $request->input('name');
    $validator = Validator::make($request->all(), ['name' => 'required']);

    if ($validator->fails()){
        $errors = $validator->errors();
        echo $errors;
    }
    else{
      echo "welcome ". $name;
    }

  }
Posted by: Guest on February-26-2021

Code answers related to "laravel if there are errors in request"

Browse Popular Code Answers by Language