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

📄 FlashSaleFactory.php

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

namespace Database\Factories;

use App\Modules\Catalog\Models\Product;
use App\Modules\Promotions\Models\FlashSale;
use Illuminate\Database\Eloquent\Factories\Factory;

class FlashSaleFactory extends Factory
{
    protected $model = FlashSale::class;

    public function definition(): array
    {
        return [
            'name'           => fake()->words(3, true) . ' Flash Sale',
            'vendor_id'      => null,
            'product_id'     => Product::factory(),
            'product_variant_id' => null,
            'discount_type'  => fake()->randomElement(['flat', 'percent']),
            'discount_value' => fake()->randomFloat(2, 5, 50),
            'sale_price'     => null,
            'max_qty'        => fake()->optional(0.5)->numberBetween(5, 100),
            'sold_qty'       => 0,
            'starts_at'      => now()->subHour(),
            'ends_at'        => now()->addHours(24),
            'is_active'      => true,
        ];
    }

    public function active(): static
    {
        return $this->state([
            'is_active' => true,
            'starts_at' => now()->subHour(),
            'ends_at'   => now()->addHour(),
        ]);
    }

    public function inactive(): static
    {
        return $this->state(['is_active' => false]);
    }

    public function expired(): static
    {
        return $this->state([
            'starts_at' => now()->subDay(),
            'ends_at'   => now()->subHour(),
        ]);
    }

    public function percent(float $value = 20): static
    {
        return $this->state([
            'discount_type'  => 'percent',
            'discount_value' => $value,
        ]);
    }

    public function flat(float $value = 100): static
    {
        return $this->state([
            'discount_type'  => 'flat',
            'discount_value' => $value,
        ]);
    }
}
← Back📥 Raw✏️ Edit🔒 Chmod
✨ File Manager Magic ✨