Mrs_Beginner
1 month ago
509
1
Laravel

PHP Notice: Undefined variable: factory in MyWebsite/config/database/factories/UserFactory.php

Posted 1 month ago by Mrs_Beginner

hi today i was editing my project in search.balde.php and suddenly after i run my project i faced below error:

PHP Notice:  Undefined variable: factory in MyWebsite/config/database/factories/UserFactory.php on line 17

my UserFactory.php code is like below


<?php

use Faker\Generator as Faker;

/*
|--------------------------------------------------------------------------
| Model Factories
|--------------------------------------------------------------------------
|
| This directory should contain each of the model factory definitions for
| your application. Factories provide a convenient way to generate new
| model instances for testing / seeding your application's database.
|
*/

$factory->define(App\User::class, function (Faker $faker) {
    return [
        'name' => $faker->name,
        'email' => $faker->unique()->safeEmail,
        'password' => 'y$TKh8H1.PfQx37YgCzwiKb.KjNyWgaHb9cbcoQgdIVFlYg7B77UdFm', // secret
        'remember_token' => str_random(10),
    ];
});

and $factory->define(App\User::class, function (Faker $faker) { is line 17.

i am pretty sure that i didn't touched UserFactory.php today. i restored my search.blade.php to when website was fine but this error was still there. i am completely mixed up now an this error makes me crazy. can any one help me on this issue?

Please sign in or create an account to participate in this conversation.