Skip to main content
Eventify ships with a complete seeding pipeline that turns a blank database into a fully working local environment in seconds. A single Artisan command wipes and recreates every table, runs all migrations, and then sequences through four dedicated seeders before generating realistic sample content with Eloquent factories. The result is a database that contains two roles, six event categories, three availability statuses, a ready-to-use admin account, and thirty sample events — everything you need to explore the application without any manual data entry.
php artisan migrate:fresh drops every table in your database before recreating it. Running this command against a production database will cause irreversible data loss. Only ever use it in local or staging environments.

Running the seeders

The fastest way to get a clean, fully seeded database is:
This command drops all existing tables, re-runs every migration in timestamp order, and then invokes DatabaseSeeder. If your schema is already up to date and you only want to re-seed without re-running migrations, use:
Re-running db:seed on a database that already contains data may cause duplicate-entry errors for seeders that do not use firstOrCreate. It is safer to always use migrate:fresh --seed during development.

Seeder execution order

DatabaseSeeder calls each seeder and factory in a strict sequence to respect foreign key dependencies.
1

RolesTableSeeder

Creates the Administrator and User roles. Must run first because users.role_id is a foreign key into roles.
2

CategoryTableSeeder

Inserts the six built-in event categories. Must exist before events are generated by the factory.
3

StatusTableSeeder

Inserts the three availability statuses. Must exist before events are generated, since events.status_id defaults to 1.
4

UserTableSeeder

Creates the default admin account. The admin user must exist before the EventFactory can assign user_id values to events.
5

User::factory()->count(5)->create()

Generates five additional random users via Faker so the EventFactory has a pool of users to assign as event organisers.
6

Location::factory()->count(30)->create()

Generates thirty random venue records. The EventFactory assigns locations sequentially, so locations must be created first.
7

Event::factory()->count(30)->create()

Generates thirty sample events, each with a random name, description, capacity, price, category, and a sequential location assignment.
The corresponding DatabaseSeeder::run() method looks like this:

RolesTableSeeder

RolesTableSeeder uses firstOrCreate to insert the two application roles, making it safe to run more than once without creating duplicates.
The users.role_id column defaults to 2, so every account created without an explicit role is automatically assigned the User role.

CategoryTableSeeder

CategoryTableSeeder inserts six categories that cover the primary event types offered on the platform.

StatusTableSeeder

StatusTableSeeder inserts three statuses that reflect the availability lifecycle of an event.
Because events.status_id defaults to 1, every newly created event starts as Disponible unless a different value is specified explicitly.

UserTableSeeder

UserTableSeeder creates a single default admin account that is ready to use immediately after seeding.
The seeded admin credentials are intentionally simple for local development. Change the email address and password before deploying to any publicly accessible environment.

Factories

After the explicit seeders run, DatabaseSeeder uses three Eloquent factories to generate bulk sample data.

UserFactory

Generates five random users. Each factory-created user receives a Faker-generated name, a unique safe email address, a verified timestamp, and the same hashed default password (123456789). No explicit role_id is set, so each user inherits the column default of 2 (User role).

LocationFactory

Generates thirty venue records using Faker’s address helpers. Latitude and longitude are populated with full decimal-degree precision, giving every sample event a realistic map-ready location.

EventFactory

Generates thirty events. Locations are assigned sequentially (starting from id = 1) so that each event receives a unique venue. The organising user and category are each picked at random from the existing records. Event images are downloaded from picsum.photos and stored in the public disk under events/.
The EventFactory makes live HTTP requests to picsum.photos to fetch cover images during seeding. Ensure your development machine has outbound internet access before running migrate:fresh --seed, or the factory will throw a connection error.

Resetting and re-seeding

To return your local database to a clean, fully seeded state at any point:
This is the recommended workflow during development whenever you need a predictable starting dataset — for example, before running feature tests manually or after pulling schema changes from a teammate.
migrate:fresh drops all tables and recreates them from scratch. Never run this command against a production or shared staging database.