From ecaf14625b78230bafdd5b8f33dc7c492159126c Mon Sep 17 00:00:00 2001 From: lukacavic Date: Sat, 12 Oct 2024 15:47:35 +0200 Subject: [PATCH] Show main information in lead overview page --- .../LeadResource/Pages/LeadOverview.php | 74 ++++++++++++++++++- .../pages/lead-overview.blade.php | 2 + 2 files changed, 74 insertions(+), 2 deletions(-) diff --git a/app/Filament/Resources/LeadResource/Pages/LeadOverview.php b/app/Filament/Resources/LeadResource/Pages/LeadOverview.php index efa0092..4ae3041 100644 --- a/app/Filament/Resources/LeadResource/Pages/LeadOverview.php +++ b/app/Filament/Resources/LeadResource/Pages/LeadOverview.php @@ -4,23 +4,93 @@ use App\Filament\Resources\LeadResource; use AymanAlhattami\FilamentPageWithSidebar\Traits\HasPageSidebar; +use Filament\Actions\Action; +use Filament\Actions\DeleteAction; +use Filament\Actions\EditAction; +use Filament\Infolists\Components\Fieldset; +use Filament\Infolists\Components\Grid; +use Filament\Infolists\Components\TextEntry; +use Filament\Infolists\Concerns\InteractsWithInfolists; +use Filament\Infolists\Contracts\HasInfolists; +use Filament\Infolists\Infolist; use Filament\Resources\Pages\Concerns\InteractsWithRecord; use Filament\Resources\Pages\Page; use Illuminate\Contracts\Support\Htmlable; -class LeadOverview extends Page +class LeadOverview extends Page implements HasInfolists { - use HasPageSidebar, InteractsWithRecord; + use HasPageSidebar, InteractsWithRecord, InteractsWithInfolists; protected static string $resource = LeadResource::class; protected static string $view = 'filament.resources.lead-resource.pages.lead-overview'; + private static function generalInformationSection() + { + return Fieldset::make('General Information') + ->columnSpan(1) + ->columns(1) + ->schema([ + TextEntry::make('status.name') + ->badge() + ->label(__('Status')), + + TextEntry::make('source.name') + ->label(__('Source')), + + TextEntry::make('assignedUser.full_name') + ->label(__('Assigned User')) + ]); + } + + private static function leadInformationSection() + { + return Fieldset::make('Lead Information') + ->columnSpan(1) + ->columns(1) + ->schema([ + TextEntry::make('company') + ]); + } + public function getTitle(): string|Htmlable { return __('Overview'); } + public function leadInformationInfolist(Infolist $infolist): Infolist + { + return $infolist + ->record($this->record) + ->schema([ + Grid::make(2)->schema([ + self::leadInformationSection(), + self::generalInformationSection() + ]) + ]); + } + + protected function getHeaderActions(): array + { + return [ + Action::make('convert') + ->label(__('Convert to client')) + ->icon('heroicon-o-user') + ->color('success'), + + EditAction::make() + ->hiddenLabel() + ->icon('heroicon-o-pencil') + ->form(function ($form) { + return LeadResource::form($form); + }), + + DeleteAction::make() + ->hiddenLabel() + ->icon('heroicon-o-trash') + ]; + } + public function mount(int|string $record): void { $this->record = $this->resolveRecord($record); diff --git a/resources/views/filament/resources/lead-resource/pages/lead-overview.blade.php b/resources/views/filament/resources/lead-resource/pages/lead-overview.blade.php index cc61477..8ca78aa 100644 --- a/resources/views/filament/resources/lead-resource/pages/lead-overview.blade.php +++ b/resources/views/filament/resources/lead-resource/pages/lead-overview.blade.php @@ -1,3 +1,5 @@ + {{ $this->leadInformationInfolist }} +