url(ListEggCollections::getUrl()), ]; } protected function getRedirectUrl(): string { return $this->getResource()::getUrl('index'); } protected function mutateFormDataBeforeCreate(array $data): array { $data['total_eggs'] = array_sum($this->eggs ?? []); $data['production_date'] = now(); return $data; } protected function afterCreate(): void { foreach ($this->eggs as $chickenId => $eggsCount) { if ($eggsCount <= 0) { continue; } EggCollectionItem::create([ 'egg_collection_id' => $this->record->id, 'chicken_id' => $chickenId, 'eggs_count' => $eggsCount, ]); } $this->eggs = []; } protected function getCreatedNotification(): ?Notification { return Notification::make() ->title('Data Berhasil Disimpan') ->body('Data baru telah berhasil ditambahkan dan disimpan oleh sistem.') ->success(); } }