mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-20 06:24:44 +02:00

* add own action classes for egg actions * add empty state to ListEggs * put Import before Create
31 lines
746 B
PHP
31 lines
746 B
PHP
<?php
|
|
|
|
namespace App\Filament\Components\Tables\Actions;
|
|
|
|
use App\Models\Egg;
|
|
use App\Services\Eggs\Sharing\EggExporterService;
|
|
use Filament\Tables\Actions\Action;
|
|
|
|
class ExportEggAction extends Action
|
|
{
|
|
public static function getDefaultName(): ?string
|
|
{
|
|
return 'export';
|
|
}
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
$this->label('Export');
|
|
|
|
$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'));
|
|
}
|
|
}
|