CheckboxList::make('courses')
->label('Select Courses')
->options(ShopProduct::all()->whereNotNull('single_course')->pluck('product_name','single_course'))
->required()
->reactive()
->searchable()
->columns(3)
->gridDirection('row')
->extraAttributes(['class'=>'overflow-y-auto h-96 p-2'])
->rules([
fn (Get $get): Closure => function (string $attribute, $value, Closure $fail) use ($get) {
if (isset($this->product->automation->shop_trigger_automation['action']) && ($this->product->automation->shop_trigger_automation['action'] === 'select_learning_courses')) {
if($this->product->automation->shop_trigger_automation['quantity'] != count($value)) {
$fail("Please select any {$this->product->automation->shop_trigger_automation['quantity']} courses.");
}
}
},
])
CheckboxList::make('courses')
->label('Select Courses')
->options(ShopProduct::all()->whereNotNull('single_course')->pluck('product_name','single_course'))
->required()
->reactive()
->searchable()
->columns(3)
->gridDirection('row')
->extraAttributes(['class'=>'overflow-y-auto h-96 p-2'])
->rules([
fn (Get $get): Closure => function (string $attribute, $value, Closure $fail) use ($get) {
if (isset($this->product->automation->shop_trigger_automation['action']) && ($this->product->automation->shop_trigger_automation['action'] === 'select_learning_courses')) {
if($this->product->automation->shop_trigger_automation['quantity'] != count($value)) {
$fail("Please select any {$this->product->automation->shop_trigger_automation['quantity']} courses.");
}
}
},
])