Skip to content

Commit

Permalink
Fix imports
Browse files Browse the repository at this point in the history
  • Loading branch information
Baspa committed Dec 1, 2024
1 parent 6be1186 commit beae1d8
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions src/Resources/MediaResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@

namespace Vormkracht10\MediaPicker\Resources;

use Filament\Facades\Filament;
use Filament\Forms\Form;
use Filament\Forms\Get;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Forms\Get;
use Filament\Forms\Form;
use Filament\Tables\Table;
use Illuminate\Support\Str;
use Filament\Facades\Filament;
use Filament\Resources\Resource;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\Section;
use Filament\Forms\Components\FileUpload;
use Vormkracht10\MediaPicker\MediaPickerPlugin;

class MediaResource extends Resource
Expand Down Expand Up @@ -82,10 +85,10 @@ public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Section::make('Media Details')
Section::make('Media Details')
->columns(2)
->schema([
Forms\Components\FileUpload::make('media')
FileUpload::make('media')
->label(__('File(s)'))
->disk(config('media-picker.disk'))
->directory(config('media-picker.directory'))
Expand All @@ -95,17 +98,17 @@ public static function form(Form $form): Form
->required()
->columnSpanFull(),

Forms\Components\Select::make('model_type')
Select::make('model_type')
->label(__('Model Type'))
->options(function () {
return collect(config('media-picker.file_upload.models'))
->mapWithKeys(fn ($model) => [$model => $model::getLabel()])
->mapWithKeys(fn($model) => [$model => $model::getLabel()])
->toArray();
})
->columnSpan(1)
->live(), // Add live() to make it reactive

Forms\Components\Select::make('model_id')
Select::make('model_id')
->label(__('Model'))
->options(function (Get $get) {
$selectedModelType = $get('model_type');
Expand All @@ -117,7 +120,7 @@ public static function form(Form $form): Form
return $selectedModelType::all()->pluck('name', 'id');
})
->columnSpan(1)
->disabled(fn (Get $get) => ! $get('model_type')), // Disable until model type is selected
->disabled(fn(Get $get) => ! $get('model_type')), // Disable until model type is selected
]),
]);
}
Expand Down Expand Up @@ -149,4 +152,4 @@ public static function getPages(): array
'edit' => MediaResource\EditMedia::route('/{record}/edit'),
];
}
}
}

0 comments on commit beae1d8

Please sign in to comment.