Show data in Select, based on relation manager
I need your help with a query. In this case, the Task model, will generate all Tasks. But I only want the tasks that are in the relation manager of the project that I select via Select
public static function form(Form $form): Form
{
return $form
->schema(Card::make([
Select::make('activity_id')
->label('Activity')
->options(Activity::all()->pluck('name', 'id'))
->searchable()
->required(),
Forms\Components\Textarea::make('description')
->required()
->maxLength(500),
Forms\Components\DateTimePicker::make('date')
->withoutTime()
->required()
->columnSpan(1),
Forms\Components\TimePicker::make('time')
->withoutDate()
->withoutSeconds()
->required()
->columnSpan(1),
Select::make('project_id')
->label('Project')
->options(Project::all()->pluck('name', 'id'))
->searchable()
->required()
->columnSpan(1),
Select::make('worker_user_id')
->label('Worker')
->options(User::all()->pluck('name', 'id'))
->searchable()
->required()
->disabled(!auth()->user()->can('show_everything_time::registration'))
->default(Auth()->id())
->columnSpan(1),
Select::make('task_id')
->label('Select Task')
->options(Task::all()->pluck('name', 'id'))
->columnSpan(1),
])->columns(2));
} public static function form(Form $form): Form
{
return $form
->schema(Card::make([
Select::make('activity_id')
->label('Activity')
->options(Activity::all()->pluck('name', 'id'))
->searchable()
->required(),
Forms\Components\Textarea::make('description')
->required()
->maxLength(500),
Forms\Components\DateTimePicker::make('date')
->withoutTime()
->required()
->columnSpan(1),
Forms\Components\TimePicker::make('time')
->withoutDate()
->withoutSeconds()
->required()
->columnSpan(1),
Select::make('project_id')
->label('Project')
->options(Project::all()->pluck('name', 'id'))
->searchable()
->required()
->columnSpan(1),
Select::make('worker_user_id')
->label('Worker')
->options(User::all()->pluck('name', 'id'))
->searchable()
->required()
->disabled(!auth()->user()->can('show_everything_time::registration'))
->default(Auth()->id())
->columnSpan(1),
Select::make('task_id')
->label('Select Task')
->options(Task::all()->pluck('name', 'id'))
->columnSpan(1),
])->columns(2));
}