notCharles 61da930909 wip
2025-04-24 19:03:34 -04:00

31 lines
791 B
PHP

<?php
namespace App\Filament\Components\Tables\Actions;
use App\Models\Egg;
use App\Services\Eggs\Sharing\EggExporterService;
use Filament\Actions\Action;
class ExportEggAction extends Action
{
public static function getDefaultName(): ?string
{
return 'export';
}
protected function setUp(): void
{
parent::setUp();
$this->label(trans('filament-actions::export.modal.actions.export.label'));
$this->icon('tabler-download');
$this->authorize(fn () => auth()->user()->can('export egg'));
$this->action(fn (EggExporterService $service, Egg $egg) => response()->streamDownload(function () use ($service, $egg) {
echo $service->handle($egg->id);
}, 'egg-' . $egg->getKebabName() . '.json'));
}
}