🚀 Hostinger Optimized
🖥️ Server: LiteSpeed
💻 System: Linux s20058.bom1.stableserver.net 5.14.0-611.55.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue May 19 15:19:29 EDT 2026 x86_64
👤 User: skhata (1324)
🐘 PHP: 8.4.20
🚫 Disabled: ✨ NONE

💻 Terminal

📁 /home/skhata/chandrasons.com/public
$

📄 PublishScheduledProductsCommand.php

📁 Path: /home/skhata/new.chandrapharma.com/app/Console/Commands/PublishScheduledProductsCommand.php
📊 Size: 1.09 KB
🔒 Perm: 0644
📝 MIME: text/x-php
<?php

namespace App\Console\Commands;

use App\Modules\Catalog\Models\Product;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;

/**
 * Scheduled: every 5 minutes (see Console/Kernel.php)
 *
 * Publishes products whose publish_at timestamp has passed
 * and whose status is still 'scheduled'.
 */
class PublishScheduledProductsCommand extends Command
{
    protected $signature   = 'products:publish-scheduled';
    protected $description = 'Publish products whose scheduled publish time has arrived';

    public function handle(): int
    {
        $count = Product::where('status', 'scheduled')
            ->where('published_at', '<=', now())
            ->update(['status' => 'active']);

        if ($count > 0) {
            Log::info("PublishScheduledProducts: activated {$count} product(s)");

            // Re-index in search engine
            Product::where('status', 'active')
                ->where('published_at', '<=', now())
                ->where('published_at', '>=', now()->subMinutes(6))
                ->searchable();
        }

        return Command::SUCCESS;
    }
}
← Back📥 Raw✏️ Edit🔒 Chmod
✨ File Manager Magic ✨