kdion4891/valiant

Making field optional on listing screen?

Closed this issue · 2 comments

Hi,

I created a relationship between two models but it is optional. For example, when creating a model called article, it has a category field which is optional. But if I create an article without category, on the article listing screen, it's looking for category.name. How can I make the category field optional on the article listing screen?

Thanks!

Just add withDefault(['name' => null]) to your belongsTo relationship.

That worked. Thank you!