diff --git a/app/Enums/Channel.php b/app/Enums/Channel.php index 3221ffe..53ef484 100644 --- a/app/Enums/Channel.php +++ b/app/Enums/Channel.php @@ -9,12 +9,13 @@ enum Channel: string implements HasLabel { use WithComment; - case WEBSITE = 'Website'; - case TIKTOK = 'Tiktok'; - case YOUTUBE = 'Youtube'; - case FACEBOOK = 'Facebook'; - case INSTAGRAM = 'Instagram'; - case OTHER = 'Other'; + case WEBSITE = 'website'; + case TIKTOK = 'tiktok'; + case YOUTUBE = 'youtube'; + case FACEBOOK = 'facebook'; + case INSTAGRAM = 'instagram'; + case TWITTER = 'twitter'; + case OTHER = 'other'; public function getLabel(): ?string { @@ -24,10 +25,24 @@ public function getLabel(): ?string self::YOUTUBE => 'Youtube', self::FACEBOOK => 'Facebook', self::INSTAGRAM => 'Instagram', + self::TWITTER => 'Twitter', self::OTHER => 'Other', }; } + public function getColor(): string + { + return match ($this) { + self::WEBSITE => 'info', + self::TIKTOK => 'success', + self::YOUTUBE => 'warning', + self::FACEBOOK => 'danger', + self::INSTAGRAM => 'primary', + self::TWITTER => 'secondary', + self::OTHER => 'gray', + }; + } + public static function options(): array { return collect(self::cases()) diff --git a/app/Enums/ContentType.php b/app/Enums/ContentType.php index 98ca33e..e61de1a 100644 --- a/app/Enums/ContentType.php +++ b/app/Enums/ContentType.php @@ -25,6 +25,16 @@ public function getLabel(): ?string }; } + public function getColor(): string + { + return match ($this) { + self::FOTO => 'info', + self::TEXT => 'success', + self::GRAPHIC => 'warning', + self::VIDEO => 'danger', + }; + } + public static function options(): array { return collect(self::cases()) diff --git a/app/Filament/Exports/ContentRecapExcelExport.php b/app/Filament/Exports/ContentRecapExcelExport.php index 2201dc8..9f8f757 100644 --- a/app/Filament/Exports/ContentRecapExcelExport.php +++ b/app/Filament/Exports/ContentRecapExcelExport.php @@ -2,8 +2,6 @@ namespace App\Filament\Exports; -use App\Enums\Channel; -use App\Enums\SocialMedia; use Maatwebsite\Excel\Concerns\WithEvents; use Maatwebsite\Excel\Concerns\WithStyles; use Maatwebsite\Excel\Events\AfterSheet; @@ -28,11 +26,11 @@ public function setUp() Column::make('channel') ->heading('Kanal') - ->formatStateUsing(fn ($state) => Channel::tryFrom($state)?->getLabel() ?? $state), + ->formatStateUsing(fn ($state) => $state->getLabel()), Column::make('social_media') ->heading('Media Sosial') - ->formatStateUsing(fn ($state) => SocialMedia::tryFrom($state)?->getLabel() ?? $state), + ->formatStateUsing(fn ($state) => $state?->getLabel()), Column::make('classification.name') ->heading('Klasifikasi'), diff --git a/app/Filament/Resources/Monitoring/ContentRecaps/Tables/ContentRecapsTable.php b/app/Filament/Resources/Monitoring/ContentRecaps/Tables/ContentRecapsTable.php index 5c1d63c..a6d1ca6 100644 --- a/app/Filament/Resources/Monitoring/ContentRecaps/Tables/ContentRecapsTable.php +++ b/app/Filament/Resources/Monitoring/ContentRecaps/Tables/ContentRecapsTable.php @@ -13,6 +13,7 @@ use App\Filament\Actions\DefaultBulkActions; use App\Filament\Columns\TimestampColumns; use App\Filament\Exports\ContentRecapExcelExport; +use App\Models\ContentRecap; use Filament\Actions\BulkActionGroup; use Filament\Forms\Components\DatePicker; use Filament\Forms\Components\Select; @@ -37,15 +38,20 @@ public static function configure(Table $table): Table ->label('Judul') ->searchable() ->sortable() - ->wrap(), + ->wrap() + ->description(fn (ContentRecap $contentRecap): string => $contentRecap->link), TextColumn::make('type') ->label('Tipe') + ->badge() + ->color(fn (ContentType $state): string => $state->getColor()) ->searchable() ->sortable(), TextColumn::make('channel') ->label('Kanal') + ->badge() + ->color(fn (Channel $state): string => $state->getColor()) ->searchable() ->sortable(), @@ -59,11 +65,6 @@ public static function configure(Table $table): Table ->searchable() ->sortable(), - TextColumn::make('link') - ->label('Tautan') - ->searchable() - ->sortable(), - TextColumn::make('posting_date') ->label('Tgl Posting') ->searchable() diff --git a/app/Models/ContentRecap.php b/app/Models/ContentRecap.php index 804371c..7348839 100644 --- a/app/Models/ContentRecap.php +++ b/app/Models/ContentRecap.php @@ -2,7 +2,9 @@ namespace App\Models; +use App\Enums\Channel; use App\Enums\ContentType; +use App\Enums\SocialMedia; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; @@ -21,6 +23,8 @@ protected function casts(): array { return [ 'type' => ContentType::class, + 'channel' => Channel::class, + 'social_media' => SocialMedia::class, 'posting_date' => 'date', 'classification_id' => 'integer', ];