schema([ Section::make('Gallery Form') ->schema([ Grid::make(1) ->schema([ TextInput::make('name'), ]), FileUpload::make('image')->image() ->enableDownload()->directory('gallery') ->getUploadedFileNameForStorageUsing(function (TemporaryUploadedFile $file): string { return (string) str($file->getClientOriginalName())->prepend(now()->timestamp); }), TextInput::make('alt_text')->placeholder('Enter Image Text'), ])->columns(2) ]); } public static function table(Table $table): Table { return $table ->columns([ TextColumn::make('name')->searchable(), ImageColumn::make('image'), TextColumn::make('alt_text'), TextColumn::make('created_at'), ]) ->filters([ // ]) ->actions([ Tables\Actions\EditAction::make(), Tables\Actions\DeleteAction::make() ->after(function (Gallery $record) { // delete single if ($record->image) { Storage::disk('public')->delete($record->image); } // delete multiple /*if ($record->galery) { foreach ($record->galery as $ph) Storage::disk('public/storage')->delete($ph); }*/ }), ]); } public static function getRelations(): array { return [ // ]; } public static function getPages(): array { return [ 'index' => Pages\ListGalleries::route('/'), 'create' => Pages\CreateGallery::route('/create'), 'edit' => Pages\EditGallery::route('/{record}/edit'), ]; } }