Reputation: 1359
I am trying to store 1 if checkbox is checked, otherwise 0. The form is
<x-checkbox name="visibility" id="visibility">{{ __('Make this visible') }}</x-checkbox>
In the controller, it is only storing the first value of the condition. This is always storing 0.
$request->visibility = 'checked' ? $package->visibility = 0 : $package->visibility = 1;
This is always storing 1.
$request->visibility = 'checked' ? $package->visibility = 1 : $package->visibility = 0;
Thanks in advance.
Upvotes: 0
Views: 379
Reputation: 34668
This is working for me :
$model->visibility = ($request->visibility) ? '1' : '0';
Upvotes: 1