label('Crawl Berita') ->color('slate') ->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) { CheerfulNotification::success( CheerfulNotification::getByKey('crawl.success'), CheerfulNotification::getByKey('news.content.fetch_success', ['count' => $count, 'data__keyword' => $data['keyword']]) )->send(); } else { CheerfulNotification::info( CheerfulNotification::getByKey('news.no_new_data'), CheerfulNotification::getByKey('news.content.fetch_empty', ['data__keyword' => $data['keyword']]) )->send(); } }) ->modalWidth(Width::Large); } }