From cfc703a8ac117f7eb457a996c3d75f60b69bce9b Mon Sep 17 00:00:00 2001 From: Rafael Blum Date: Fri, 26 Jul 2024 12:22:24 -0300 Subject: [PATCH] feat: add link produto modal infolist --- app/Filament/App/FreezerApp.php | 18 +++++++++++++----- app/Filament/Resources/ProductResource.php | 15 +++++++++++++++ 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/app/Filament/App/FreezerApp.php b/app/Filament/App/FreezerApp.php index 42bdb01..60a357b 100644 --- a/app/Filament/App/FreezerApp.php +++ b/app/Filament/App/FreezerApp.php @@ -6,6 +6,7 @@ use App\Filament\Forms\Components\PtbrMoney; use App\Filament\Resources\OrderResource; use App\Filament\Resources\ProductResource; +use App\Models\Order; use App\Models\Product; use Filament\Forms\Components\Grid; use Filament\Forms\Components\Hidden; @@ -126,11 +127,21 @@ public function table(Table $table): Table Stack::make([ ImageColumn::make('image') ->height('100%') - ->width('100%'), + ->width('100%') + ->action( + ViewAction::make()->label('') + ->infolist(fn(Infolist $infolist) => ProductResource::infolist($infolist)) + ->form(fn(Form $form) => ProductResource::form($form))->icon('heroicon-m-eye')->tooltip('Ver mais'), + ), Stack::make([ TextColumn::make('name') ->weight(FontWeight::ExtraBold) - ->alignCenter()->size(200), + ->alignCenter()->size(200) + ->action( + ViewAction::make()->label('') + ->infolist(fn(Infolist $infolist) => ProductResource::infolist($infolist)) + ->form(fn(Form $form) => ProductResource::form($form))->icon('heroicon-m-eye')->tooltip('Ver mais'), + ), ]), Split::make([ @@ -170,9 +181,6 @@ public function table(Table $table): Table ->icon('heroicon-m-plus-circle') ->color(Color::Teal) ->url(fn(Product $record): string => '#' . urlencode($record->url)), - ViewAction::make()->label('') - ->infolist(fn(Infolist $infolist) => ProductResource::infolist($infolist)) - ->form(fn(Form $form) => ProductResource::form($form))->icon('heroicon-m-eye')->tooltip('Ver mais'), ActionGroup::make([ EditAction::make()->form(fn(Form $form) => ProductResource::form($form)), DeleteAction::make(), diff --git a/app/Filament/Resources/ProductResource.php b/app/Filament/Resources/ProductResource.php index ebfc1ac..ee52945 100644 --- a/app/Filament/Resources/ProductResource.php +++ b/app/Filament/Resources/ProductResource.php @@ -6,9 +6,14 @@ use App\Filament\Forms\Components\PtbrMoney; use App\Filament\Resources\ProductResource\Pages; +use App\Models\Blog\Link; use App\Models\Product; use Filament\Forms; use Filament\Forms\Form; +use Filament\Infolists\Components\ColorEntry; +use Filament\Infolists\Components\ImageEntry; +use Filament\Infolists\Components\TextEntry; +use Filament\Infolists\Infolist; use Filament\Resources\Resource; use Filament\Tables; use Filament\Tables\Table; @@ -65,6 +70,16 @@ public static function form(Form $form): Form ]); } + public static function infolist(Infolist $infolist): Infolist + { + return $infolist + ->schema([ + TextEntry::make('name'), + TextEntry::make('sale_price'), + ImageEntry::make('image'), + ]); + } + public static function table(Table $table): Table { return $table