Repeater relationship returns null

So, I have an issue where my relationship can't be found by repeater in my custom page, I want it to display every 'pergunta' inside the table formulario but I can't find the solution , this is the error returned:

Call to a member function cargoFormulario() on null

here's the code:
class Perguntas extends Page implements HasForms
{
    use InteractsWithForms;

    protected static ?string $model = Pergunta::class;

now the forms:
return $form
            ->schema([
                Repeater::make('cargoFormulario')
                
                    ->relationship()
                    ->schema([
                        TextInput::make('texto')
                    ])
            ]);

my model:
class Pergunta extends Model
{
    protected $table = 'formularios';
    protected $guarded = ['id'];
    use HasFactory;

    public function cargoFormulario()
    {
        $this->hasMany(CargoFormulario::class, 'id', 'formulario_id');   
    }
}


Only to give you guys more context about what I'm doing, a 'cargo' has many 'formulario' and a 'formulario' has many 'cargo'.
Solution
you can also do:

$form->model($this->record)

then
Was this page helpful?