How to transform to the correct type? #273
Answered
by
francoism90
francoism90
asked this question in
Q&A
-
I'm using Livewire, this is my class PostData extends Data implements Wireable
{
use WireableData;
public function __construct(
public Optional|string $id,
public Optional|null|Carbon $published_at,
) {
}
public static function fromModel(Post $model): self
{
return new self(
id: $model->getRouteKey(),
published_at: $model->published_at,
);
}
} Blade: <input type="datetime-local" wire:model="post.published_at"> Result:
I could add How can I make sure it always returns a Carbon or DateTime value? Thanks. |
Beta Was this translation helpful? Give feedback.
Answered by
francoism90
Nov 28, 2022
Replies: 1 comment
-
Answer here: livewire/livewire#5385 (reply in thread) |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
francoism90
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Answer here: livewire/livewire#5385 (reply in thread)