I want to have a default value of false but I cannt get it to work.
Maybe the issue is that it is a field on a computed property (a mutator).
Here is the nova resource code
BooleanGroup::make('Booleans')->options([
'no_bill_brooklyn' => 'No Bill Brooklyn',
'no_bill_upstate' => 'No Bill Upstate',
'no_book_brooklyn' => 'No Book Brooklyn',
'no_book_upstate' => 'No Book Upstate',
'wta_brooklyn' => 'Wta Brooklyn',
'wta_upstate' => 'Wta Upstate',
'pot_brooklyn' => 'Pot Brooklyn',
'pot_upstate' => 'Pot Upstate',
'must_pay' => 'Must Pay',
'to_go_collect' => 'To Go Collect',
]),
And here is the attribute method on the model class.
protected function booleans(): Attribute
{
return Attribute::make(
get: fn () => [
'no_bill_brooklyn' => $this->no_bill_brooklyn === 'n' ? false : true,
'no_bill_upstate' => $this->no_bill_upstate === 'n' ? false : true,
'no_book_brooklyn' => $this->no_book_brooklyn === 'n' ? false : true,
'no_book_upstate' => $this->no_book_upstate === 'n' ? false : true,
'wta_brooklyn' => $this->wta_brooklyn === 'n' ? false : true,
'wta_upstate' => $this->wta_upstate === 'n' ? false : true,
'pot_brooklyn' => $this->pot_brooklyn === 'n' ? false : true,
'pot_upstate' => $this->pot_upstate === 'n' ? false : true,
'must_pay' => $this->must_pay === 'n' ? false : true,
'to_go_collect' => $this->to_go_collect === 'n' ? false : true,
],
set: fn ($value) => [
'no_bill_brooklyn' => $value['no_bill_brooklyn'] === true ? 'y' : 'n',
'no_bill_upstate' => $value['no_bill_upstate'] === true ? 'y' : 'n',
'no_book_brooklyn' => $value['no_book_brooklyn'] === true ? 'y' : 'n',
'no_book_upstate' => $value['no_book_upstate'] === true ? 'y' : 'n',
'wta_brooklyn' => $value['wta_brooklyn'] === true ? 'y' : 'n',
'wta_upstate' => $value['wta_upstate'] === true ? 'y' : 'n',
'pot_brooklyn' => $value['pot_brooklyn'] === true ? 'y' : 'n',
'pot_upstate' => $value['pot_upstate'] === true ? 'y' : 'n',
'must_pay' => $value['must_pay'] === true ? 'y' : 'n',
'to_go_collect' => $value['to_go_collect'] === true ? 'y' : 'n',
],
);
}
Any help?