HasOne
You're browsing the documentation for an old version of MoonShine. Consider upgrading your project to MoonShine 2.x.
Field for relationships in Laravel, hasOne type
Creates a new record in the linked table and binds it to the current record
In case of relationship the record is edited
use MoonShine\Fields\HasOne; //...public function fields(): array{ return [ HasOne::make('City', 'city', 'name') ->fields([ ID::make(), Text::make('Value', 'name'), ]) ];}//...
ID in the fields method is required
It often happens that there are a lot of fields for relations and they look small in the table, and this is inconvenient.
In many cases, you have to move this relation to a separate resource, however if you must leave it within the current resource,
but display the fields completely, you can use
the fullPage()
method, and the fields will get a standard shape


resourceMode
is also available, details in the HasMany field