Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel nova - How to remove required validation from BelongsTo relationship?

I have a Nova resource named "Partner" with relationship to another Nove resource named "Rate".

BelongsTo::make('Rate*', 'customrate', 'App\Nova\Rate')->onlyOnForms()

Now when user try to create a parter, the select field to choose rate is mandatory.

Client doesn`t want to keep it mandatory to choose a rate for partner. Any solution for this problem?

like image 811
Vineeth Vijayan Avatar asked Dec 04 '22 19:12

Vineeth Vijayan


1 Answers

Use nullable() which is added in version 1.1.7

BelongsTo::make('Rate*', 'customrate', 'App\Nova\Rate')
    ->onlyOnForms()
    ->nullable()
like image 164
Saumini Navaratnam Avatar answered Dec 11 '22 16:12

Saumini Navaratnam