Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Neeraj1005's avatar

PHP Error: Class 'Database/Factories/BookingEventFactory' not found in C:/laragon/www/acl/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Factories/Factory.php

In my terminal using running the tinker cli. It send me this type of error. Can someone plz tell me what i did wrong. I am using the laravel 8.9.0 version.

Note: Basically I've upgraded my project form laravel 7 to laravel 8 and I've installed the legacy pkg for factroy.

λ php artisan tinker
Psy Shell v0.10.4 (PHP 7.4.8 — cli) by Justin Hileman
>>> use App\{User,BookingEvent,BookingService};
>>> BookingEvent::factory()->count(3)->for(BookingService::factory())->create();
PHP Error:  Class 'Database/Factories/BookingEventFactory' not found in C:/laragon/www/acl/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Factories/Factory.php on line 656

This is my BookingEventFactory

<?php

namespace Database\Factories;

use App\BookingEvent;
use App\BookingService;
use Illuminate\Database\Eloquent\Factories\Factory;

class BookingEventFactory extends Factory
{
    /**
     * The name of the factory's corresponding model.
     *
     * @var string
     */
    protected $model = BookingEvent::class;

    /**
     * Define the model's default state.
     *
     * @return array
     */
    public function definition()
    {
        return [
            'event_name' => $this->faker->name,
            'user_id' => 2,
            'booking_service_id' => BookingService::factory(),
            'duration' => '1 Hours',
            'price' => '1000',
            'event_description' => $this->faker->paragraph,
        ];
    }
}

0 likes
2 replies

Please or to participate in this conversation.