Is there a way to generate A proper content for Department and Course Using Laravel Faker?

30 Views Asked by At

I have created a Laravel Student Table. I need to insert a dummy data with the following table columns name, email, department, course

Generating proper Fake Data for the email and name is easy. But I can't get proper data for department and course. Right now I can only generate some texts which do not look like Department and Course of Study.

<?php

namespace Database\Factories;

use Illuminate\Database\Eloquent\Factories\Factory;

/**
 * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Student>
 */
class StudentFactory extends Factory
{
    /**
     * Define the model's default state.
     *
     * @return array<string, mixed>
     */
    public function definition(): array
    {
        return [
           'name' => fake()->name(),
           'email' => fake()->unique()->safeEmail(),
           'department' => fake()->realText($maxNbChars = 20),
           'course' => fake()->realText($maxNbChars = 20)
        ];
    }
}

I have tried to create proper data

0

There are 0 best solutions below