Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/astrxnomo/eventify-app/llms.txt

Use this file to discover all available pages before exploring further.

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:
php artisan migrate:fresh --seed
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:
php artisan db:seed
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:
public function run()
{
    $this->call(RolesTableSeeder::class);
    $this->call(CategoryTableSeeder::class);
    $this->call(StatusTableSeeder::class);
    $this->call(UserTableSeeder::class);

    User::factory()->count(5)->create();
    Location::factory()->count(30)->create();
    Event::factory()->count(30)->create();
}

RolesTableSeeder

RolesTableSeeder uses firstOrCreate to insert the two application roles, making it safe to run more than once without creating duplicates.
Role::firstOrCreate(['name' => 'Administrator', 'label' => 'admin',  'description' => 'System Administrator']);
Role::firstOrCreate(['name' => 'User',          'label' => 'user',   'description' => 'Regular User']);
idnamelabeldescription
1AdministratoradminSystem Administrator
2UseruserRegular User
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.
Category::create(['name' => 'Musical']);
Category::create(['name' => 'Teatro']);
Category::create(['name' => 'Deportivo']);
Category::create(['name' => 'Cultural']);
Category::create(['name' => 'Familiar']);
Category::create(['name' => 'Gastronómico']);
idname
1Musical
2Teatro
3Deportivo
4Cultural
5Familiar
6Gastronómico

StatusTableSeeder

StatusTableSeeder inserts three statuses that reflect the availability lifecycle of an event.
Status::create(['name' => 'Disponible']);
Status::create(['name' => 'Agotado']);
Status::create(['name' => 'Finalizado']);
idnameMeaning
1DisponibleTickets are available for purchase.
2AgotadoThe event is sold out; no tickets remain.
3FinalizadoThe event has concluded.
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.
User::create([
    'name'               => 'Admin',
    'email'              => 'admin@admin.com',
    'email_verified_at'  => now(),
    'password'           => Hash::make('123456789'),
    'remember_token'     => Str::random(10),
    'role_id'            => 1,
]);
FieldValue
NameAdmin
Emailadmin@admin.com
Password123456789
RoleAdministrator (1)
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).
// database/factories/UserFactory.php
public function definition(): array
{
    return [
        'name'               => fake()->name(),
        'email'              => fake()->unique()->safeEmail(),
        'email_verified_at'  => now(),
        'password'           => Hash::make('123456789'),
        'remember_token'     => Str::random(10),
    ];
}

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.
// database/factories/LocationFactory.php
public function definition()
{
    return [
        'address'   => $this->faker->address,
        'city'      => $this->faker->city,
        'region'    => $this->faker->state,
        'country'   => $this->faker->country,
        'latitude'  => $this->faker->latitude,
        'longitude' => $this->faker->longitude,
    ];
}

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/.
// database/factories/EventFactory.php
public function definition()
{
    static $location_id = 1;

    // Download a random placeholder image and store it in public storage
    $client = new Client();
    $response = $client->get('https://picsum.photos/800/600');
    $imageContent = $response->getBody()->getContents();
    $imageName = 'events/' . uniqid() . '.jpg';
    Storage::disk('public')->put($imageName, $imageContent);

    return [
        'name'        => $this->faker->sentence,
        'description' => implode(' ', $this->faker->paragraphs(15)),
        'img_url'     => $imageName,
        'capacity'    => $this->faker->numberBetween(10, 100),
        'price'       => $this->faker->randomFloat(2, 10000, 100000),
        'user_id'     => User::inRandomOrder()->first()->id,
        'category_id' => Category::inRandomOrder()->first()->id,
        'location_id' => $location_id++,
        'start_date'  => $this->faker->dateTimeBetween('now', '+1 year'),
        'end_date'    => $this->faker->dateTimeBetween('+1 year', '+2 years'),
    ];
}
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:
php artisan migrate:fresh --seed
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.

Build docs developers (and LLMs) love