Skip to content

Commit

Permalink
feat: adding download button
Browse files Browse the repository at this point in the history
  • Loading branch information
rupadana committed Mar 28, 2024
1 parent 4eefd7e commit f1129a1
Showing 4 changed files with 18 additions and 3 deletions.
7 changes: 5 additions & 2 deletions app/Filament/Resources/DatabaseResource.php
Original file line number Diff line number Diff line change
@@ -48,7 +48,9 @@ public static function form(Form $form): Form
->required(),
TextInput::make('username')
->required(),
TextInput::make('password'),
TextInput::make('password')
->password()
->revealable(),
])
])
->maxItems(1)
@@ -76,7 +78,8 @@ public static function table(Table $table): Table
})
->beforeReplicaSaved(function (Database $replica, array $data) {
$replica->fill($data);
})
}),

])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Original file line number Diff line number Diff line change
@@ -44,6 +44,10 @@ public function table(Table $table): Table
Tables\Columns\TextColumn::make('created_at')
])
->actions([
Tables\Actions\Action::make('download')
->label('Download')
->openUrlInNewTab()
->url(fn(\App\Models\BackupHistory $record) => url('/download/' . $record->filename)),
Tables\Actions\DeleteAction::make(),
])
->bulkActions([
2 changes: 1 addition & 1 deletion app/Http/Middleware/Authenticate.php
Original file line number Diff line number Diff line change
@@ -12,6 +12,6 @@ class Authenticate extends Middleware
*/
protected function redirectTo(Request $request): ?string
{
return $request->expectsJson() ? null : route('login');
return $request->expectsJson() ? null : route('filament.admin.auth.login');
}
}
8 changes: 8 additions & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
@@ -14,3 +14,11 @@
*/

Route::get('/', fn() => redirect('/admin'));

Route::middleware('auth')->group(function () {
Route::get('/download/{filename}', function($filename) {
$storage = \Illuminate\Support\Facades\Storage::disk('databases');

return $storage->download($filename);
});
});

0 comments on commit f1129a1

Please sign in to comment.