Dependent file upload option based on select field in form

I need to have a different directory for an file upload field based on a selected option:

so I have an option in a select field:

Select::make('first')
    ->options([
        'one' => 'One',
        'two' => 'Two',
        'three' => 'Three',
    ])
    ->live(),
    
FileUpload::make('second')
    ->disk('s3')
    ->directory('download' . '/' . <here-will-be-one-two-or-three>)


How to add one or two or three instead of here-will-be-one-two-or-three placeholder based on what I select in the 'first' select box?

Basically, I want to store the file in different folders based on what the user selects in options of select box.
Was this page helpful?