where('name','Technology')->first(); if (!is_null($category)) { $hour = rand(0, 23); $minute = rand(0, 59); $schedule->call(function () use ($category) { $shopee_seller_category = \App\Models\ShopeeSellerCategory::where('category_id', $category->id)->where(function($query) { $query->whereNull('last_ai_written_at') ->orWhere('last_ai_written_at', '=', \App\Models\ShopeeSellerCategory::whereNotNull('last_ai_written_at')->orderBy('last_ai_written_at', 'asc')->value('last_ai_written_at')); })->first(); $task = ShopeeSellerTopProductScraperJob::dispatch($shopee_seller_category->seller, $category->country_locale->country_iso, $category) ->onQueue('default') ->onConnection('default'); })->dailyAt("{$hour}:{$minute}"); } } /** * Register the commands for the application. */ protected function commands(): void { $this->load(__DIR__.'/Commands'); require base_path('routes/console.php'); } }