Some stupid annoying things I've encountered with Livewire.
In some code examples, imagine we are building some property management platform.
Want to pass some nullable property? Is it a model? Well you better not type-hint it.
Wrong!:
# user manage their property, but maybe they don't have one
# on the system, so instead we can show find/claim instead of manage..
public function mount(User $user, ?Property $property)
For some inexplicable reason it decides to throw an exception.
ImplicitlyBoundMethod::getImplicitBinding
Correct:
public function mount(User $user, $property)
Customising the value in the validator message is kinda ugly (not entirely Livewire's doing).
$after = Reminders::getMinDate(now()->toImmutable());
$rules['reminder_date'][] = 'after_or_equal:' . $after->format('Y-m-d');
// custom property (or function) livewire looks for to call `setCustomValues` or something on the validator instance
$this->validationCustomValues = [
'reminder_date' => [$after->format('Y-m-d') => $after->format('d/m/Y')],
];