🚀 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
$

📄 ProductFactory.php

📁 Path: /home/skhata/new.chandrapharma.com/database/factories/ProductFactory.php
📊 Size: 1.92 KB
🔒 Perm: 0600
📝 MIME: text/x-php
<?php

namespace Database\Factories;

use App\Modules\Catalog\Models\Product;
use App\Modules\Vendor\Models\Vendor;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;

class ProductFactory extends Factory
{
    protected $model = Product::class;

    public function definition(): array
    {
        $name = fake()->words(3, true);

        return [
            'vendor_id'          => Vendor::factory(),
            'name'               => ['en' => ucwords($name), 'ne' => ucwords($name)],
            // Str::random() rather than fake()->unique()->numerify('####'):
            // the 4-digit pool (10,000 combos) was getting exhausted partway
            // through a full test-suite run, since Faker's unique() registry
            // is shared for the life of the PHP process, not reset per test —
            // VendorPlanServiceTest's "unlimited products" test alone creates
            // enough products to hit the OverflowException.
            'slug'               => Str::slug($name) . '-' . Str::lower(Str::random(8)),
            'product_type'       => 'simple',
            'price'              => fake()->randomFloat(2, 50, 5000),
            'currency'           => 'NPR',
            'track_inventory'    => true,
            'stock_quantity'     => fake()->numberBetween(10, 100),
            'low_stock_threshold'=> 5,
            'allow_backorder'    => false,
            'status'             => 'active',
            'requires_shipping'  => true,
            'tax_exempt'         => false,
            'is_featured'        => false,
        ];
    }

    public function outOfStock(): static
    {
        return $this->state(['stock_quantity' => 0]);
    }

    public function lowStock(): static
    {
        return $this->state(['stock_quantity' => 2, 'low_stock_threshold' => 5]);
    }

    public function trackingDisabled(): static
    {
        return $this->state(['track_inventory' => false]);
    }
}
← Back📥 Raw✏️ Edit🔒 Chmod
✨ File Manager Magic ✨