- Added comprehensive parameter and return type hinting to closures across various Filament resources, actions, and relation managers to improve type safety and static analysis. - Fixed logic in ReportRelationManager where report count was incorrectly compared, preventing the 'Buat Laporan' button from showing correctly. - Corrected namespaces for RepeatableEntry and TextEntry in ViewCooperation (changed from Filament\Schemas to Filament\Infolists). - Fixed component rendering in JournalistResource form by ensuring sections are correctly returned in the mapping. - Added @var docblocks to resolve lint errors related to auth()->user() and verified query builder return types. - Standardized file retrieval logic in PartnerResource and improved overall code reliability."
67 lines
2.3 KiB
PHP
67 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\Monitoring\MediaMonitorings\Actions;
|
|
|
|
use App\Models\Theme;
|
|
use App\Services\NewsCrawlerService;
|
|
use Filament\Actions\Action;
|
|
use Filament\Forms\Components\Select;
|
|
use Filament\Forms\Components\TextInput;
|
|
use Filament\Notifications\Notification;
|
|
use Filament\Support\Enums\Width;
|
|
use Filament\Support\Icons\Heroicon;
|
|
|
|
class CrawlNewsAction extends Action
|
|
{
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
$this->label('Crawl Berita')
|
|
->icon(Heroicon::MagnifyingGlass)
|
|
->color('info')
|
|
->schema([
|
|
TextInput::make('keyword')
|
|
->label('Kata Kunci')
|
|
->placeholder('Pendidikan, UMKM, Pariwisata')
|
|
->autocomplete(false)
|
|
->autofocus()
|
|
->required()
|
|
->helperText('Jika kata kunci nya lebih dari 1, pisahkan dengan koma.'),
|
|
|
|
Select::make('theme_id')
|
|
->label('Tema')
|
|
->required()
|
|
->options(Theme::active()->pluck('name', 'id'))
|
|
->searchable()
|
|
->multiple(),
|
|
|
|
TextInput::make('limit')
|
|
->label('Jumlah Berita')
|
|
->placeholder(10)
|
|
->numeric()
|
|
->required()
|
|
->default(10)
|
|
->autocomplete(false),
|
|
])
|
|
->action(function (array $data, NewsCrawlerService $service): void {
|
|
$count = $service->crawlFromGoogleNews($data['keyword'], $data['limit'], (array) ($data['theme_id'] ?? []));
|
|
|
|
if ($count > 0) {
|
|
Notification::make()
|
|
->title('Crawl Selesai')
|
|
->body("Berhasil mengambil {$count} berita baru tentang '{$data['keyword']}' di Purwakarta.")
|
|
->success()
|
|
->send();
|
|
} else {
|
|
Notification::make()
|
|
->title('Tidak Ada Berita Baru')
|
|
->body("Tidak ditemukan berita baru untuk '{$data['keyword']}' yang belum ada di database.")
|
|
->info()
|
|
->send();
|
|
}
|
|
})
|
|
->modalWidth(Width::Large);
|
|
}
|
|
}
|