Making field optional on listing screen?
Closed this issue · 2 comments
seongbae commented
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!
kdion4891 commented
Just add withDefault(['name' => null])
to your belongsTo
relationship.
seongbae commented
That worked. Thank you!