Why validator only return validation.required not the message in res/lang/xx/validator.php ?

Posted 1 year ago by ReakyMark

this is my code at backend

$validator = Validator::make(
                'title'        => 'required',
                'url'          => 'nullable',
                'upload_slide' => 'required|image|mimes:jpeg,png,jpg,gif|max:2048',

return redirect()->back()

this is my code at Frontend

@if ($errors->any())  
        $errorMessage = '';
        $i = 1;
    @foreach ($errors->all() as $error )
       <?php $errorMessage .= $i++.': '.$error .'<br>'; ?>
    {!! $createMessage->make($errorMessage, 'alert-danger') !!}

code above result in 1: validation.required ....etc what is my problem ?

if i want show message i have to custom it with

$message = [
            'title.required' => 'Please fill Title',
            'url.required' => 'Please fill url',
            'upload_slide.required' => 'Please add image to upload',
            'upload_slide.mimes'    => 'Extension not supported',
            'upload_slide.max'    => 'File is bigger than 2MB'

code above result in 1: Please fill Title ....etc

Please sign in or create an account to participate in this conversation.