simedkom/app/Filament/Resources/Manage/Cooperations/RelationManagers/TaskAssignmentRelationManager.php
Yoga Pangestu 2983cd243f refactor: centralize cheerful notifications and cleanup auth calls
- Introduce `CheerfulNotification` utility class to standardize cheerful and expressive notifications across the application.
- Refactor custom "Cheerful" actions (Create, Edit, Delete, etc.) and `DefaultBulkActions` to utilize the new utility class.
- Update all `ToggleColumn` status updates in Master Data modules to use `CheerfulNotification::statusUpdated()`.
- Replace inline `Notification::make()` calls in custom actions (Reply, Crawl News, Cooperation actions) and Resource Pages with `CheerfulNotification` methods.
- Address various lint errors by standardizing the use of the `Auth` facade and improving type hinting for the authenticated `User` model.
2026-01-14 09:54:46 +07:00

149 lines
5.1 KiB
PHP

<?php
namespace App\Filament\Resources\Manage\Cooperations\RelationManagers;
use App\Enums\ApprovalStatus;
use Filament\Actions\BulkActionGroup;
use Filament\Actions\CreateAction;
use Filament\Actions\DeleteAction;
use Filament\Actions\DeleteBulkAction;
use Filament\Actions\EditAction;
use Filament\Forms\Components\DatePicker;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput;
use Filament\Notifications\Notification;
use Filament\Resources\RelationManagers\RelationManager;
use Filament\Schemas\Schema;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
class TaskAssignmentRelationManager extends RelationManager
{
protected static string $relationship = 'taskAssignments';
protected static ?string $title = 'Penugasan';
public function form(Schema $schema): Schema
{
return $schema
->components([
DatePicker::make('start_date')
->label('Tanggal Mulai')
->required()
->native(false)
->autocomplete(false)
->autofocus(),
DatePicker::make('end_date')
->label('Tanggal Selesai')
->required()
->native(false)
->after('start_date')
->autocomplete(false),
Textarea::make('task_description')
->label('Deskripsi Tugas')
->required()
->rows(4)
->maxLength(65535)
->autocomplete(false),
TextInput::make('report_amount')
->label('Jumlah Laporan')
->numeric()
->required()
->minValue(1)
->default(1)
->autocomplete(false),
Select::make('partner_media_ids')
->label('Media yang Ditugaskan')
->relationship('partnerMedia', 'name')
->multiple()
->preload()
->required()
->autocomplete(false),
Select::make('status')
->options(ApprovalStatus::options())
->required()
->default(ApprovalStatus::PENDING),
Textarea::make('rejection_reason')
->label('Alasan Penolakan')
->rows(3)
->columnSpanFull()
->autocomplete(false),
]);
}
public function table(Table $table): Table
{
return $table
->recordTitleAttribute('task_description')
->columns([
TextColumn::make('start_date')
->label('Mulai')
->date('l, d F Y'),
TextColumn::make('end_date')
->label('Selesai')
->date('l, d F Y'),
TextColumn::make('task_description')
->label('Deskripsi Tugas')
->limit(50),
TextColumn::make('report_amount')
->label('Jumlah Laporan'),
])
->filters([
//
])
->headerActions([
CreateAction::make()
->label('Buat Penugasan')
->visible(function (): bool {
$cooperation = $this->getOwnerRecord();
return $cooperation->proposals()->accepted()->exists();
})
->successNotification(
Notification::make()
->title('Penugasan Dibuat! 🚀✨')
->body('Tugas baru berhasil ditetapkan. Media terkait akan segera mengetahuinya! 💪')
->success()
),
])
->recordActions([
EditAction::make()
->successNotification(
Notification::make()
->title('Penugasan Diperbarui! ✅')
->body('Perubahan pada penugasan berhasil disimpan. 👍')
->success()
),
DeleteAction::make()
->successNotification(
Notification::make()
->title('Penugasan Dihapus! 🗑️')
->body('Penugasan telah berhasil dihapus dari sistem. 👋')
->success()
),
])
->toolbarActions([
BulkActionGroup::make([
DeleteBulkAction::make()
->successNotification(
Notification::make()
->title('Banyak Penugasan Dihapus! 🗑️👋')
->body('Semua penugasan yang dipilih telah dihapus. 🧹')
->success()
),
]),
]);
}
}