feat: Introduce Issue Management module, refactor enum implementations, and remove rich editors from location forms.
This commit is contained in:
parent
f9f1e60b2e
commit
ae31d8f37f
@ -3,11 +3,11 @@
|
||||
namespace App\Enums;
|
||||
|
||||
use App\Traits\Enum\WithComment;
|
||||
use App\Traits\Enum\WithValue;
|
||||
use Filament\Support\Contracts\HasLabel;
|
||||
|
||||
enum Channel: string
|
||||
enum Channel: string implements HasLabel
|
||||
{
|
||||
use WithComment, WithValue;
|
||||
use WithComment;
|
||||
|
||||
case WEBSITE = 'Website';
|
||||
case TIKTOK = 'Tiktok';
|
||||
@ -16,11 +16,22 @@ enum Channel: string
|
||||
case INSTAGRAM = 'Instagram';
|
||||
case OTHER = 'Other';
|
||||
|
||||
public function getLabel(): ?string
|
||||
{
|
||||
return match ($this) {
|
||||
self::WEBSITE => 'Website',
|
||||
self::TIKTOK => 'Tiktok',
|
||||
self::YOUTUBE => 'Youtube',
|
||||
self::FACEBOOK => 'Facebook',
|
||||
self::INSTAGRAM => 'Instagram',
|
||||
self::OTHER => 'Other',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return array_combine(
|
||||
array_map(fn ($status) => $status->value, self::cases()),
|
||||
array_map(fn ($status) => $status->value, self::cases())
|
||||
);
|
||||
return collect(self::cases())
|
||||
->mapWithKeys(fn ($case) => [$case->value => $case->getLabel()])
|
||||
->toArray();
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,22 +2,33 @@
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use App\Traits\Enum\WithComment;
|
||||
use App\Traits\Enum\WithValue;
|
||||
use Filament\Support\Contracts\HasLabel;
|
||||
|
||||
enum ContentType: string
|
||||
enum ContentType: string implements HasLabel
|
||||
{
|
||||
use WithValue;
|
||||
use WithComment, WithValue;
|
||||
|
||||
case FOTO = 'Foto';
|
||||
case TEXT = 'Teks';
|
||||
case GRAPHIC = 'Grafis';
|
||||
case VIDEO = 'Video';
|
||||
|
||||
public function getLabel(): ?string
|
||||
{
|
||||
return match ($this) {
|
||||
self::FOTO => 'Foto',
|
||||
self::TEXT => 'Teks',
|
||||
self::GRAPHIC => 'Grafis',
|
||||
self::VIDEO => 'Video',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return array_combine(
|
||||
array_map(fn ($status) => $status->value, self::cases()),
|
||||
array_map(fn ($status) => $status->value, self::cases())
|
||||
);
|
||||
return collect(self::cases())
|
||||
->mapWithKeys(fn ($case) => [$case->value => $case->getLabel()])
|
||||
->toArray();
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,15 +4,17 @@
|
||||
|
||||
use App\Traits\Enum\WithComment;
|
||||
use App\Traits\Enum\WithValue;
|
||||
use Filament\Support\Contracts\HasColor;
|
||||
use Filament\Support\Contracts\HasLabel;
|
||||
|
||||
enum IsActive: int
|
||||
enum IsActive: int implements HasColor, HasLabel
|
||||
{
|
||||
use WithComment, WithValue;
|
||||
|
||||
case ACTIVE = 1;
|
||||
case INACTIVE = 2;
|
||||
|
||||
public function label()
|
||||
public function getLabel(): ?string
|
||||
{
|
||||
return match ($this) {
|
||||
self::ACTIVE => 'Aktif',
|
||||
@ -20,11 +22,18 @@ public function label()
|
||||
};
|
||||
}
|
||||
|
||||
public function color()
|
||||
public function getColor(): string|array|null
|
||||
{
|
||||
return match ($this) {
|
||||
self::ACTIVE => 'success',
|
||||
self::INACTIVE => 'danger',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())
|
||||
->mapWithKeys(fn ($case) => [$case->value => $case->getLabel()])
|
||||
->toArray();
|
||||
}
|
||||
}
|
||||
|
||||
46
app/Enums/IssueSentiment.php
Normal file
46
app/Enums/IssueSentiment.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use App\Traits\Enum\WithComment;
|
||||
use App\Traits\Enum\WithValue;
|
||||
use Filament\Support\Colors\Color;
|
||||
use Filament\Support\Contracts\HasColor;
|
||||
use Filament\Support\Contracts\HasLabel;
|
||||
|
||||
enum IssueSentiment: string implements HasColor, HasLabel
|
||||
{
|
||||
use WithComment, WithValue;
|
||||
|
||||
case POSITIVE = 'positive';
|
||||
case NEGATIVE = 'negative';
|
||||
case NEUTRAL = 'neutral';
|
||||
case CRISIS = 'krisis';
|
||||
|
||||
public function getLabel(): ?string
|
||||
{
|
||||
return match ($this) {
|
||||
self::POSITIVE => 'Positif',
|
||||
self::NEGATIVE => 'Negatif',
|
||||
self::NEUTRAL => 'Netral',
|
||||
self::CRISIS => 'Krisis',
|
||||
};
|
||||
}
|
||||
|
||||
public function getColor(): string|array|null
|
||||
{
|
||||
return match ($this) {
|
||||
self::POSITIVE => Color::Green,
|
||||
self::NEGATIVE => Color::Red,
|
||||
self::NEUTRAL => Color::Gray,
|
||||
self::CRISIS => Color::Orange,
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())
|
||||
->mapWithKeys(fn ($case) => [$case->value => $case->getLabel()])
|
||||
->toArray();
|
||||
}
|
||||
}
|
||||
@ -4,8 +4,9 @@
|
||||
|
||||
use App\Traits\Enum\WithComment;
|
||||
use App\Traits\Enum\WithValue;
|
||||
use Filament\Support\Contracts\HasLabel;
|
||||
|
||||
enum MediaClassification: int
|
||||
enum MediaClassification: int implements HasLabel
|
||||
{
|
||||
use WithComment, WithValue;
|
||||
|
||||
@ -13,7 +14,7 @@ enum MediaClassification: int
|
||||
case REGIONAL = 2;
|
||||
case NATIONAL = 3;
|
||||
|
||||
public function label()
|
||||
public function getLabel(): ?string
|
||||
{
|
||||
return match ($this) {
|
||||
self::LOCAL => 'Lokal',
|
||||
@ -24,9 +25,8 @@ public function label()
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return array_combine(
|
||||
array_map(fn ($status) => $status->value, self::cases()),
|
||||
array_map(fn ($status) => $status->label(), self::cases())
|
||||
);
|
||||
return collect(self::cases())
|
||||
->mapWithKeys(fn ($case) => [$case->value => $case->getLabel()])
|
||||
->toArray();
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,8 +4,9 @@
|
||||
|
||||
use App\Traits\Enum\WithComment;
|
||||
use App\Traits\Enum\WithValue;
|
||||
use Filament\Support\Contracts\HasLabel;
|
||||
|
||||
enum MediaType: int
|
||||
enum MediaType: int implements HasLabel
|
||||
{
|
||||
use WithComment, WithValue;
|
||||
|
||||
@ -14,7 +15,7 @@ enum MediaType: int
|
||||
case RADIO = 3;
|
||||
case TELEVISION = 4;
|
||||
|
||||
public function label()
|
||||
public function getLabel(): ?string
|
||||
{
|
||||
return match ($this) {
|
||||
self::ONLINE => 'Online',
|
||||
@ -26,9 +27,8 @@ public function label()
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return array_combine(
|
||||
array_map(fn ($status) => $status->value, self::cases()),
|
||||
array_map(fn ($status) => $status->label(), self::cases())
|
||||
);
|
||||
return collect(self::cases())
|
||||
->mapWithKeys(fn ($case) => [$case->value => $case->getLabel()])
|
||||
->toArray();
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,21 +2,30 @@
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use App\Traits\Enum\WithValue;
|
||||
use App\Traits\Enum\WithComment;
|
||||
use Filament\Support\Contracts\HasLabel;
|
||||
|
||||
enum SocialMedia: string
|
||||
enum SocialMedia: string implements HasLabel
|
||||
{
|
||||
use WithValue;
|
||||
use WithComment;
|
||||
|
||||
case PPID_DISKOMINFO_PURWAKARTA = 'PPID Diskominfo Purwakarta';
|
||||
case DISKOMINFO_PURWAKARTA = 'Diskominfo Purwakarta';
|
||||
case PURWAKARTA_SABER_HOAKS = 'Purwakarta Saber Hoaks';
|
||||
|
||||
public function getLabel(): ?string
|
||||
{
|
||||
return match ($this) {
|
||||
self::PPID_DISKOMINFO_PURWAKARTA => 'PPID Diskominfo Purwakarta',
|
||||
self::DISKOMINFO_PURWAKARTA => 'Diskominfo Purwakarta',
|
||||
self::PURWAKARTA_SABER_HOAKS => 'Purwakarta Saber Hoaks',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return array_combine(
|
||||
array_map(fn ($status) => $status->value, self::cases()),
|
||||
array_map(fn ($status) => $status->value, self::cases())
|
||||
);
|
||||
return collect(self::cases())
|
||||
->mapWithKeys(fn ($case) => [$case->value => $case->getLabel()])
|
||||
->toArray();
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,7 +13,6 @@
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Actions\ForceDeleteAction;
|
||||
use Filament\Actions\RestoreAction;
|
||||
use Filament\Forms\Components\RichEditor;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
@ -53,11 +52,6 @@ public static function form(Schema $schema): Schema
|
||||
->autofocus()
|
||||
->required()
|
||||
->maxLength(50),
|
||||
|
||||
RichEditor::make('description')
|
||||
->label('Keterangan')
|
||||
->placeholder('Silakan isi keterangan klasifikasi di atas')
|
||||
->nullable(),
|
||||
])
|
||||
->columns(1);
|
||||
}
|
||||
|
||||
@ -13,7 +13,6 @@
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Actions\ForceDeleteAction;
|
||||
use Filament\Actions\RestoreAction;
|
||||
use Filament\Forms\Components\RichEditor;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
@ -53,11 +52,6 @@ public static function form(Schema $schema): Schema
|
||||
->autofocus()
|
||||
->required()
|
||||
->maxLength(50),
|
||||
|
||||
RichEditor::make('description')
|
||||
->label('Keterangan')
|
||||
->placeholder('Silakan isi keterangan lokasi di atas')
|
||||
->nullable(),
|
||||
])
|
||||
->columns(1);
|
||||
}
|
||||
|
||||
@ -14,7 +14,6 @@
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Actions\ForceDeleteAction;
|
||||
use Filament\Actions\RestoreAction;
|
||||
use Filament\Forms\Components\RichEditor;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Resources\Resource;
|
||||
@ -42,7 +41,7 @@ class SubClassificationResource extends Resource
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
protected static ?int $navigationSort = 1;
|
||||
protected static ?int $navigationSort = 2;
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
@ -50,7 +49,7 @@ public static function form(Schema $schema): Schema
|
||||
->components([
|
||||
Select::make('classification_id')
|
||||
->label('Klasifikasi')
|
||||
->options(Classification::query()->pluck('name', 'id'))
|
||||
->options(Classification::query()->active()->pluck('name', 'id'))
|
||||
->searchable()
|
||||
->native(false)
|
||||
->required()
|
||||
@ -58,16 +57,11 @@ public static function form(Schema $schema): Schema
|
||||
|
||||
TextInput::make('name')
|
||||
->label('Nama')
|
||||
->placeholder('Nagrikaler')
|
||||
->placeholder('Korupsi')
|
||||
->autocomplete(false)
|
||||
->autofocus()
|
||||
->required()
|
||||
->maxLength(50),
|
||||
|
||||
RichEditor::make('description')
|
||||
->label('Keterangan')
|
||||
->placeholder('Silakan isi keterangan sub klasifikasi di atas')
|
||||
->nullable(),
|
||||
])
|
||||
->columns(1);
|
||||
}
|
||||
|
||||
@ -14,7 +14,6 @@
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Actions\ForceDeleteAction;
|
||||
use Filament\Actions\RestoreAction;
|
||||
use Filament\Forms\Components\RichEditor;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Resources\Resource;
|
||||
@ -58,16 +57,11 @@ public static function form(Schema $schema): Schema
|
||||
|
||||
TextInput::make('name')
|
||||
->label('Nama')
|
||||
->placeholder('Pengaduan')
|
||||
->placeholder('Nagri Kaler')
|
||||
->autocomplete(false)
|
||||
->autofocus()
|
||||
->required()
|
||||
->maxLength(50),
|
||||
|
||||
RichEditor::make('description')
|
||||
->label('Keterangan')
|
||||
->placeholder('Silakan isi keterangan sub lokasi di atas')
|
||||
->nullable(),
|
||||
])
|
||||
->columns(1);
|
||||
}
|
||||
|
||||
@ -71,7 +71,7 @@ public static function configure(Schema $schema): Schema
|
||||
Section::make([
|
||||
Select::make('classification_id')
|
||||
->label('Klasifikasi')
|
||||
->relationship('classification', 'name')
|
||||
->relationship('classification', 'name', fn ($query) => $query->active())
|
||||
->native(false)
|
||||
->preload()
|
||||
->required(),
|
||||
|
||||
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Monitoring\IssueManagements;
|
||||
|
||||
use App\Filament\Resources\Monitoring\IssueManagements\Pages\CreateIssueManagement;
|
||||
use App\Filament\Resources\Monitoring\IssueManagements\Pages\EditIssueManagement;
|
||||
use App\Filament\Resources\Monitoring\IssueManagements\Pages\ListIssueManagements;
|
||||
use App\Filament\Resources\Monitoring\IssueManagements\Schemas\IssueManagementForm;
|
||||
use App\Filament\Resources\Monitoring\IssueManagements\Tables\IssueManagementTable;
|
||||
use App\Models\IssueManagement;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use UnitEnum;
|
||||
|
||||
class IssueManagementResource extends Resource
|
||||
{
|
||||
protected static ?string $model = IssueManagement::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::ExclamationCircle;
|
||||
|
||||
protected static ?string $navigationLabel = 'Manajemen Isu';
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Monitoring';
|
||||
|
||||
protected static ?string $slug = 'monitoring/issue-managements';
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'mediaMonitoring.title';
|
||||
|
||||
protected static ?int $navigationSort = 13;
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return IssueManagementForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return IssueManagementTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListIssueManagements::route('/'),
|
||||
'create' => CreateIssueManagement::route('/create'),
|
||||
'edit' => EditIssueManagement::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getRecordRouteBindingEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getRecordRouteBindingEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Monitoring\IssueManagements\Pages;
|
||||
|
||||
use App\Filament\Resources\Monitoring\IssueManagements\IssueManagementResource;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateIssueManagement extends CreateRecord
|
||||
{
|
||||
protected static string $resource = IssueManagementResource::class;
|
||||
|
||||
protected static ?string $title = 'Tambah Manajemen Isu';
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return $this->getResource()::getUrl('index');
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('back')
|
||||
->label('Kembali')
|
||||
->url(fn (): string => route('filament.dashboard.resources.monitoring.issue-managements.index'))
|
||||
->outlined()
|
||||
->color('secondary'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Monitoring\IssueManagements\Pages;
|
||||
|
||||
use App\Filament\Resources\Monitoring\IssueManagements\IssueManagementResource;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditIssueManagement extends EditRecord
|
||||
{
|
||||
protected static string $resource = IssueManagementResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('back')
|
||||
->label('Kembali')
|
||||
->url(fn (): string => route('filament.dashboard.resources.monitoring.issue-managements.index'))
|
||||
->outlined()
|
||||
->color('secondary'),
|
||||
];
|
||||
}
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return $this->getResource()::getUrl('index');
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Monitoring\IssueManagements\Pages;
|
||||
|
||||
use App\Filament\Resources\Monitoring\IssueManagements\IssueManagementResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListIssueManagements extends ListRecords
|
||||
{
|
||||
protected static string $resource = IssueManagementResource::class;
|
||||
|
||||
protected static ?string $title = 'Manajemen Isu';
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make()
|
||||
->label('Tambah'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Monitoring\IssueManagements\Schemas;
|
||||
|
||||
use App\Enums\IssueSentiment;
|
||||
use Filament\Forms\Components\RichEditor;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Schemas\Components\Grid;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Schemas\Components\Utilities\Set;
|
||||
use Filament\Schemas\Schema;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class IssueManagementForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Section::make([
|
||||
Select::make('media_monitoring_id')
|
||||
->label('Monitoring Media')
|
||||
->relationship('mediaMonitoring', 'title')
|
||||
->searchable()
|
||||
->preload()
|
||||
->required(),
|
||||
|
||||
Grid::make(2)
|
||||
->schema([
|
||||
Select::make('location_id')
|
||||
->label('Lokasi')
|
||||
->relationship('location', 'name')
|
||||
->searchable()
|
||||
->preload()
|
||||
->live()
|
||||
->afterStateUpdated(fn (Set $set) => $set('sub_location_id', null))
|
||||
->required(),
|
||||
|
||||
Select::make('sub_location_id')
|
||||
->label('Sub Lokasi')
|
||||
->relationship('subLocation', 'name', fn (Builder $query, Get $get) => $query->where('location_id', $get('location_id')))
|
||||
->searchable()
|
||||
->preload()
|
||||
->required(),
|
||||
]),
|
||||
|
||||
RichEditor::make('description')
|
||||
->label('Keterangan')
|
||||
->required()
|
||||
->columnSpanFull(),
|
||||
])->columnSpan(2),
|
||||
|
||||
Section::make([
|
||||
Select::make('issue')
|
||||
->label('Isu')
|
||||
->options(IssueSentiment::options())
|
||||
->required()
|
||||
->native(false)
|
||||
->in(implode(',', array_column(IssueSentiment::cases(), 'value'))),
|
||||
|
||||
Select::make('response')
|
||||
->label('Respon')
|
||||
->options(IssueSentiment::options())
|
||||
->required()
|
||||
->native(false)
|
||||
->in(implode(',', array_column(IssueSentiment::cases(), 'value'))),
|
||||
|
||||
Select::make('classification_id')
|
||||
->label('Klasifikasi')
|
||||
->relationship('classification', 'name', fn ($query) => $query->active())
|
||||
->searchable()
|
||||
->preload()
|
||||
->live()
|
||||
->afterStateUpdated(fn (Set $set) => $set('sub_classification_id', null))
|
||||
->required(),
|
||||
|
||||
Select::make('sub_classification_id')
|
||||
->label('Sub Klasifikasi')
|
||||
->relationship('subClassification', 'name', fn (Builder $query, Get $get) => $query->where('classification_id', $get('classification_id'))->active())
|
||||
->searchable()
|
||||
->preload()
|
||||
->required(),
|
||||
])->columnSpan(1),
|
||||
])
|
||||
->columns(3);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Monitoring\IssueManagements\Tables;
|
||||
|
||||
use App\Filament\Actions\DefaultBulkActions;
|
||||
use App\Filament\Columns\TimestampColumns;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Actions\ForceDeleteAction;
|
||||
use Filament\Actions\RestoreAction;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Filament\Tables\Filters\TrashedFilter;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class IssueManagementTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('mediaMonitoring.title')
|
||||
->label('Judul Berita')
|
||||
->limit(30)
|
||||
->searchable()
|
||||
->sortable(),
|
||||
|
||||
TextColumn::make('issue')
|
||||
->label('Isu')
|
||||
->badge()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
|
||||
TextColumn::make('response')
|
||||
->label('Respon')
|
||||
->badge()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
|
||||
TextColumn::make('location.name')
|
||||
->label('Lokasi')
|
||||
->searchable()
|
||||
->sortable(),
|
||||
|
||||
TextColumn::make('classification.name')
|
||||
->label('Klasifikasi')
|
||||
->searchable()
|
||||
->sortable(),
|
||||
|
||||
...TimestampColumns::make(),
|
||||
])
|
||||
->filters([
|
||||
TrashedFilter::make()->native(false),
|
||||
SelectFilter::make('issue')
|
||||
->label('Filter Isu')
|
||||
->options(\App\Enums\IssueSentiment::class)
|
||||
->native(false),
|
||||
SelectFilter::make('response')
|
||||
->label('Filter Respon')
|
||||
->options(\App\Enums\IssueSentiment::class)
|
||||
->native(false),
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
DeleteAction::make(),
|
||||
RestoreAction::make(),
|
||||
ForceDeleteAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
...DefaultBulkActions::make('Manajemen Isu'),
|
||||
]),
|
||||
])
|
||||
->emptyStateIcon('heroicon-o-bookmark')
|
||||
->emptyStateDescription('Setelah Anda membubat data pertama, maka akan muncul disini.')
|
||||
->defaultSort('created_at', 'desc')
|
||||
->deferFilters(false);
|
||||
}
|
||||
}
|
||||
@ -80,7 +80,7 @@ public static function configure(Schema $schema): Schema
|
||||
|
||||
Select::make('themes')
|
||||
->label('Tema')
|
||||
->relationship('themes', 'name')
|
||||
->relationship('themes', 'name', fn ($query) => $query->active())
|
||||
->native(false)
|
||||
->multiple()
|
||||
->preload()
|
||||
|
||||
@ -31,9 +31,9 @@ public static function configure(Table $table): Table
|
||||
|
||||
TextColumn::make('title')
|
||||
->label('Judul')
|
||||
->limit(30)
|
||||
->searchable()
|
||||
->sortable()
|
||||
->wrap(),
|
||||
->sortable(),
|
||||
|
||||
TextColumn::make('channel')
|
||||
->label('Kanal')
|
||||
|
||||
@ -3,6 +3,8 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\IsActive;
|
||||
use Illuminate\Database\Eloquent\Attributes\Scope;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
@ -21,6 +23,18 @@ protected function casts(): array
|
||||
];
|
||||
}
|
||||
|
||||
#[Scope]
|
||||
protected function active(Builder $query): void
|
||||
{
|
||||
$query->where('is_active', IsActive::ACTIVE);
|
||||
}
|
||||
|
||||
#[Scope]
|
||||
protected function inactive(Builder $query): void
|
||||
{
|
||||
$query->where('is_active', IsActive::INACTIVE);
|
||||
}
|
||||
|
||||
public function subClassifications(): HasMany
|
||||
{
|
||||
return $this->hasMany(SubClassification::class);
|
||||
|
||||
49
app/Models/IssueManagement.php
Normal file
49
app/Models/IssueManagement.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\IssueSentiment;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class IssueManagement extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'issue' => IssueSentiment::class,
|
||||
'response' => IssueSentiment::class,
|
||||
];
|
||||
}
|
||||
|
||||
public function location(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Location::class);
|
||||
}
|
||||
|
||||
public function subLocation(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(SubLocation::class);
|
||||
}
|
||||
|
||||
public function classification(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Classification::class);
|
||||
}
|
||||
|
||||
public function subClassification(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(SubClassification::class);
|
||||
}
|
||||
|
||||
public function mediaMonitoring(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(MediaMonitoring::class);
|
||||
}
|
||||
}
|
||||
@ -4,6 +4,7 @@
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Spatie\MediaLibrary\HasMedia;
|
||||
use Spatie\MediaLibrary\InteractsWithMedia;
|
||||
@ -18,4 +19,9 @@ public function themes(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Theme::class);
|
||||
}
|
||||
|
||||
public function issueManagement(): HasOne
|
||||
{
|
||||
return $this->hasOne(IssueManagement::class);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,6 +3,8 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\IsActive;
|
||||
use Illuminate\Database\Eloquent\Attributes\Scope;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
@ -21,6 +23,18 @@ protected function casts(): array
|
||||
];
|
||||
}
|
||||
|
||||
#[Scope]
|
||||
protected function active(Builder $query): void
|
||||
{
|
||||
$query->where('is_active', IsActive::ACTIVE);
|
||||
}
|
||||
|
||||
#[Scope]
|
||||
protected function inactive(Builder $query): void
|
||||
{
|
||||
$query->where('is_active', IsActive::INACTIVE);
|
||||
}
|
||||
|
||||
public function classification(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Classification::class);
|
||||
|
||||
@ -3,6 +3,8 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\IsActive;
|
||||
use Illuminate\Database\Eloquent\Attributes\Scope;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
@ -21,6 +23,18 @@ protected function casts(): array
|
||||
];
|
||||
}
|
||||
|
||||
#[Scope]
|
||||
protected function active(Builder $query): void
|
||||
{
|
||||
$query->where('is_active', IsActive::ACTIVE);
|
||||
}
|
||||
|
||||
#[Scope]
|
||||
protected function inactive(Builder $query): void
|
||||
{
|
||||
$query->where('is_active', IsActive::INACTIVE);
|
||||
}
|
||||
|
||||
public function mediaMonitorings(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(MediaMonitoring::class);
|
||||
|
||||
@ -6,6 +6,6 @@ trait WithComment
|
||||
{
|
||||
public static function comment(): string
|
||||
{
|
||||
return implode(', ', array_map(fn ($case) => "{$case->value}: {$case->label()}", self::cases()));
|
||||
return implode(', ', array_map(fn ($case) => "{$case->value}: {$case->getLabel()}", self::cases()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
use App\Enums\IssueSentiment;
|
||||
use App\Models\Classification;
|
||||
use App\Models\Location;
|
||||
use App\Models\MediaMonitoring;
|
||||
use App\Models\SubClassification;
|
||||
use App\Models\SubLocation;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('issue_management', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignIdFor(Location::class)->constrained()->cascadeOnDelete();
|
||||
$table->foreignIdFor(SubLocation::class)->nullable()->constrained()->nullOnDelete();
|
||||
$table->foreignIdFor(Classification::class)->constrained()->cascadeOnDelete();
|
||||
$table->foreignIdFor(SubClassification::class)->nullable()->constrained()->nullOnDelete();
|
||||
$table->foreignIdFor(MediaMonitoring::class)->constrained()->cascadeOnDelete();
|
||||
$table->enum('issue', [IssueSentiment::values()])->comment(IssueSentiment::comment());
|
||||
$table->enum('response', [IssueSentiment::values()])->comment(IssueSentiment::comment());
|
||||
$table->text('description');
|
||||
$table->timestamp('created_at')->useCurrent();
|
||||
$table->timestamp('updated_at')->nullable()->useCurrentOnUpdate();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('issue_management');
|
||||
}
|
||||
};
|
||||
Loading…
Reference in New Issue
Block a user