repeater returns single array of components instead of multiple arrays of components

please help me i need to get all products with the selected mark_id and show it in repeater
    return $form
            ->schema([
                Forms\Components\Card::make()
                    ->schema([
                        Forms\Components\Select::make('mark_id')
                            ->label('Mark')
                            ->reactive()
                            ->options(Mark::all()->pluck('name', 'id'))->required()->searchable()->reactive()
                    ])->columns(2),
                Forms\Components\Repeater::make('Products')->reactive()
                ->schema(function (\Closure $get) {
                    $markId = $get('mark_id');

                    if (!$markId) {
                        return [Forms\Components\Placeholder::make('Select Mark First')];
                    }
                    $warehouseProducts = WarehouseProducts::where('mark_id', $markId)->get();

                    if ($warehouseProducts->isEmpty()) {
                        return [Forms\Components\Placeholder::make('No products available for the selected mark')];
                    }
                    $products=[];
                         foreach ($warehouseProducts as $product) {
                                 $products[] =Forms\Components\TextInput::make('pd_id'.$product->id)
                                     ->reactive()
                                     ->default($product->product_name);
                         }
                         return  $products;
                })
              

            ]);
Was this page helpful?