Get attribute from relationship if is null

Posted 1 year ago by schmidtflo

Hey guys,

I have two models:

Model A and Model B. Both have a name attribute, on model A it's required, on B its optional. If the attribute is not null on B, i want to return this attribute. But if it's null, I want to return the inherited name from Model A in Model B.


ModelA->name: schmidtflo
ModelB->name: othername

--> ModelB[name] = othername

ModelA->name: schmidtflo
ModelB->name: null

--> ModelB[name] = schmidtflo

I can't find a solution how to define my accessor for that specific problem. Would be fine if you can help me.

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.