I tried to follow the example in the docs but am not getting the results I need.
In my component:
class StaffEditor extends Component
{
public $dob = 'birthday';
public $anniversary = 'startday';
protected $casts = [
'dob' => 'date',
'startday' => 'date',
];
public function mount($id)
{
$this->userID = $id;
$fetched = User::query()
->with('departments', 'manager', 'office')
->whereId($id)
->first();
$this->dob = $fetched->dob;
$this->anniversary = $fetched->anniversary;
} // end function
public function getBirthday()
{
return ($this->dob ? $this->dob->format('Y-m-d') : null);
} // end function
public function getStartday()
{
return ($this->anniversary ? $this->anniversary->format('Y-m-d') : null);
} // end function
public function render()
{
return view('_livewire.staff.staff-editor');
} // end function
In my blade:
<div class="w-1/3">
<label class="tw-label">Birthday</label>
<input type="text" class="tw-input"
wire:model="dob">
</div>
<div class="w-1/3">
<label class="tw-label">Start Date</label>
<input type="text" class="tw-input"
wire:model="anniversary">
</div>
Results: image below as coded and if I comment out $this->anniversary = $fetched->anniversary;