Help on how to take field values and use them inside Repeater::make fields
I want to take the ID from user_id and work with it in the products field
Forms\Components\Select::make('user_id')
->label('Client')
->options(function () {
return \App\Models\User::whereHas('roles', function ($query) {
$query->where('name', 'client');
})->pluck('name', 'id');
})
I want to add some percentages according to the customer in the products, and for this I need to bring the customer's ID ( user_id )
Forms\Components\Repeater::make('items')
->hidden(fn (Get $get): bool => ! $get('user_id'))
->visible(fn (Get $get): bool => (bool) $get('user_id'))
->relationship()
->schema([
Forms\Components\Select::make('product_id')
->label('Designation')
->options(Products::pluck('name', 'id'))
->required()
->reactive()
->afterStateUpdated(function ( $state, callable $get, callable $set) {
}),
])
1 Reply
I got over this issue by :
$get('../../user_id')