Is using ?? in form filling code a good practice for null records?

Is using something like this:
public function mount(): void
{
$website = Website::find(1);

$this->form->fill([
'number_of_lives' => $website['number_of_lives'],
]);
}
public function mount(): void
{
$website = Website::find(1);

$this->form->fill([
'number_of_lives' => $website['number_of_lives'],
]);
}
But if there is a null record returned from the DB there will be an error. So, I tried altering the code like this using the ?? operator:
public function mount(): void
{
$website = Website::find(1);

$this->form->fill([
'number_of_lives' => $website['number_of_lives'] ?? '',
]);
}
public function mount(): void
{
$website = Website::find(1);

$this->form->fill([
'number_of_lives' => $website['number_of_lives'] ?? '',
]);
}
and it seems to work. The question is whether it's the best approach. What is the recommended way in Filament to deal with this null issue in this case?
1 Reply
LeandroFerreira
LeandroFerreira6mo ago
$this->form->fill([
'number_of_lives' => $website->number_of_lives
]);
$this->form->fill([
'number_of_lives' => $website->number_of_lives
]);
?