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

📄 UserFactory.php

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

namespace Database\Factories;

use App\Modules\User\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;

class UserFactory extends Factory
{
    protected $model = User::class;

    public function definition(): array
    {
        return [
            'name'      => fake()->name(),
            'email'     => fake()->unique()->safeEmail(),
            'phone'     => fake()->unique()->numerify('98########'),
            'password'  => Hash::make('password'),
            // Verified by default — most tests create an already-onboarded
            // customer/staff account. Under Model::shouldBeStrict(), leaving
            // this (and vendor_id below) entirely unset meant the in-memory
            // factory instance (used directly by actingAs()/Livewire::actingAs(),
            // which never re-fetches from the DB) threw MissingAttributeException
            // the moment anything touched hasVerifiedEmail() or the vendor
            // relation — see ->unverified() for tests that need the opposite.
            'email_verified_at' => now(),
            'vendor_id' => null,
            'locale'    => 'en',
            'currency'  => 'NPR',
            'timezone'  => 'Asia/Kathmandu',
            'is_active' => true,
            'remember_token' => Str::random(10),
        ];
    }

    public function unverified(): static
    {
        return $this->state(fn () => ['email_verified_at' => null]);
    }

    public function admin(): static
    {
        return $this->afterCreating(fn (User $u) => $u->assignRole('admin'));
    }

    public function customer(): static
    {
        return $this->afterCreating(fn (User $u) => $u->assignRole('customer'));
    }

    public function vendor(): static
    {
        return $this->afterCreating(fn (User $u) => $u->assignRole('vendor'));
    }
}
← Back📥 Raw✏️ Edit🔒 Chmod
✨ File Manager Magic ✨