View more context

it seems my old code that does this for SS3 does not work

In silverstripe 4 how would you tell if a hasOne relationship is set or filled? I have has one relationship called "Discount" on my Product (DataObject) class. I want to do something like "If this product has a discount record associated with it do..."

Ahh thank you, I was looking for the

  1. !$record->Relationship()->exists()
which I have used before in the past

But I guess

  1. $record->Discount() !== null
would work to

I always thought there was something special about exist() behind the scenes. I never thought of just testing for a null value\