Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

David Orizu's avatar

Laravel validate time and date error

Hello guys please I need some help with this laravel error "Method Illuminate\Validation\Validator::validateTime does not exist."

This is my Controller

public function expectingpost(Request $request)
    {

        DB::table('expectings') ->insert([

            $validatedData = $request->validate([
                "time" => 'required|time_format:00:00',
                "day" => 'required|date_format:d/m/Y',
                "name" => 'required|name'
            ]).

            "time" => $request->time,
            "day" => $request->date,
            "name" => $request->name
        ]);

        return back() -> with('expecting', $request->input('name') . ' has been added as your guest');
    }
}

And also my blade.php

<form action="{{route('expecting.post')}}" method="post" class="expecting-form">
              @csrf
              
              @error('time')
                <div class="alert alert-danger" style="width: 100%;">
                   <span>{{$message}}</span>
                </div>
                @enderror
                @error('day')
                 <div class="alert alert-danger" style="width: 100%;">
                   <span>{{$message}}</span>
                   </div>
                @enderror
                @error('name')
                <div class="alert alert-danger" style="width: 100%;">
                   <span>{{$message}}</span>
                   </div>
                @enderror
              <div class="col-md-12">
                <label for="time" class="form-label"><strong>Time of Visit</strong></label>
                <input type="time" class="form-control" name="time" id="time" placeholder="Time of Visit">
              </div>
              <br>
              <div class="col-md-12">
                <label for="date" class="form-label"><strong>Day of Visit</strong></label>
                <input type="date" class="form-control" name="date" id="date" placeholder="Day of Visit">
              </div>
              <br>
              <div class="col-md-12">
                <label for="name" class="form-label"><strong>Name of Person</strong></label>
                <input type="text" class="form-control" id="name" name="name" placeholder="Name of Person">
              </div>
        </div>
        <div class="modal-footer col-11 mx-auto">
          <button type="submit" class="btn btn-confirm text-white"><b>OK</b></button>
        </div>
    </form>

Please I seriously need help. Thank you

0 likes
6 replies
Snapey's avatar

where did you dream up this rule from?

try

"time" => 'required|date_format:H:i',
David Orizu's avatar

Ok that has been solve but I now have this error "Method Illuminate\Validation\Validator::validateName does not exist." So how can I fix this please

David Orizu's avatar

Ok i have tackled this but

 "day" => 'required|date_format:d/m/Y'

seems to be having issues. Sir please I honestiy need your help

Snapey's avatar

I cannot provide an answer based on

seems to be having issues.

look at the validation rules in the docs.

Use only the rules listed, or create your own custom rules.

Please or to participate in this conversation.