$record->relationship->fieldData not working

I have a resource for persona (People in Spanish) and I am showing a column which comes from a relationship and it is working correctly.

TextColumn::make('interviniente.tipoExpediente')
                    ->label('TipoExp')


Now I need to make an action which will redirect to a different URL depending on the value in that columns TipoExp.

I have tried this:
->url(function (Persona $record){

      switch ($record->tipoExp)
      {
          case 'Herencia':
              return 'expedientes-herencia/' . $record->id;
              break;
          case 'Compra-Venta':
...


But it is returning nothing. It looks as if $record->tipoExp has nothing inside.
I have also tried to access through the related relationship, but it is not working either:

switch ($record->interviniente->tipoExpediente)


Not working either.

How could I solve this, please??
Was this page helpful?