Hello
Using integer field
Schema::create('user_groups', function (Blueprint $table) {
$table->id();
$table->string('name')->unique();
$table->integer('allow_product_read')->default(0);
$table->integer('allow_product_create')->default(0);
$table->integer('allow_product_update')->default(0);
$table->integer('allow_product_delete')->default(0);
$table->timestamps();
});
public function store(Request $request)
{
$request->validate([
'name' => 'required|string|max:255|unique:user_groups',
'allow_lead_read'=> 'integer|max:11',
'allow_lead_create'=> 'integer|max:11',
'allow_lead_update'=> 'integer|max:11',
'allow_lead_delete'=> 'integer|max:11',
]);
if I check all field it works, but if one of value is not check getting error.
my goal is that, if one of value is not check it will be 0
<div class="form-group">
<div class="form-check">
<input id="allow_lead_read" name="allow_lead_read" class="form-check-input" value="1" type="checkbox">
<label class="form-check-label">Allow Lead Read</label>
</div>
<div class="form-check">
<input id="allow_lead_create" name="allow_lead_create" class="form-check-input" value="1" type="checkbox">
<label class="form-check-label">Allow Lead Create</label>
</div>
<div class="form-check">
<input id="allow_lead_update" name="allow_lead_update" class="form-check-input" value="1" type="checkbox">
<label class="form-check-label">Allow Lead Update</label>
</div>
<div class="form-check">
<input id="allow_lead_delete" name="allow_lead_delete" class="form-check-input" value="1" type="checkbox">
<label class="form-check-label">Allow Lead Delete</label>
</div>
</div>