The issue is with the validation in the store method of the ProductController. The validate method expects an array of validation rules, but in this case, a boolean value is being passed instead. To fix this, update the validation rule to be an array with the featured field and its validation rule:
public function store(Request $request)
{
$request->validate([
'featured' => ['boolean']
]);
// rest of the code
}
Also, in the create blade file, the button tag should be outside the label tag. Here's the updated code:
<form method="post" action="{{ route('product.store') }}" enctype="multipart/form-data">
@csrf
<label for="featured" class="inline-flex relative items-center cursor-pointer">
<input type="checkbox" name="featured" class="switch-input sr-only peer" value="1" {{ old('featured') ? 'checked="checked"' : '' }}/>
<span class="peer-toggle peer-success"></span>
<span class="peer-label">Featured</span>
</label>
<button type="submit">Create</button>
</form>