Conditional form relationships

Is there a way to fetch related models, in the same form, based on another field value?

Select::make('user_id')
    ->label('User')
    ->options(User::all()->pluck('name', 'id'))
    ->required(),
Select::make('post_id')
    ->label('Post')
    ->options(Post::where('author_id', 'SELECTED-USER-ID?')->get()->pluck('name', 'id'))
    ->required(),

  1. Is there a way to list posts by the selected user? SELECTED-USER-ID
  2. Is there a way to disable the post select field until a user is selected?
Was this page helpful?