Dynamically change Form component in Repeater

Just want to say that I'm not an expert in php or laravel or filament. Basically I'm doing a quiz, and I'm facing this issue where I want some of the questions to be toggle or just a textInput, this is my current code inside repeater (only the schema):

->schema(function ($record) {

                                $userCargoFormulario = DB::table('user_cargo_formulario as ucf')
                                    ->join('cargo_formulario as cf','ucf.cargo_formulario_id','=','cf.id')
                                    ->where('ucf.user_id', auth()->id())->get('tipo_id')->toArray();

                                    // dd($userCargoFormulario);

                                    if($userCargoFormulario[0]->tipo_id == 3){
                                        return TextInput::make('resposta');
                                    }
                            })



another example is that if(tipo_id == 3) should return toggle::make('resposta')
but this is the error returned:
Was this page helpful?