54 lines
1.6 KiB
PHP
54 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Console;
|
|
|
|
use App\Jobs\ShopeeSellerTopProductScraperJob;
|
|
use App\Models\Category;
|
|
use Illuminate\Console\Scheduling\Schedule;
|
|
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
|
|
|
class Kernel extends ConsoleKernel
|
|
{
|
|
/**
|
|
* Define the application's command schedule.
|
|
*/
|
|
protected function schedule(Schedule $schedule)
|
|
{
|
|
// Schdule MY TECH Category
|
|
$category = Category::where('country_locale_slug','my')->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');
|
|
}
|
|
|
|
|
|
}
|