I am trying to use a date field that is in an eloquent model property. I have tried the alpine/Pikaday and just the strait html input date field. To try and figure things out more I created 2 fields. One as a property on the component and one as a part of the model property.
[
'date_of_birth' => 'date_format:m/d/yy',
'student.date_of_birth' => 'required|date_format:m/d/yy',
]
My problem is when I enter the date livewire sends the data back in different ways. If I send the field as ā09/19/2020ā it will send back in 2 different formats. The top level property comes back as 2020-09-01
and the student.date_of_birth comes back as 2020-09-19T00:00:00.000000Z
.
I put casting on the student model without luck because Iām guessing its a carbon object vs string output. I was looking at hydrate but not sure how to run hydrate for on the property set to an eloquent model.
Long time laravel user, brand new to livewire. Liking it a lot so far but hit a hard wall on this one.
I tried a number of ways but here are 2 versions of how I implemented using just the input type date.
<input wire:model="student.date_of_birth"
id="date_of_birth"
class="form-control {{ $errors->has('student.date_of_birth') ? 'is-invalid' : '' }}"
type="date" >
<input wire:model="date_of_birth"
id="date_of_birth"
class="form-control {{ $errors->has('date_of_birth') ? 'is-invalid' : '' }}"
type="date" >