Figured it out, I feel foolish. I just needed to exit tinker inbetween updating the files
Oct 21, 2020
2
Level 1
PHP Notice: Undefined variable: faker (laravel 8)
Postfactory.php
namespace Database\Factories;
use App\Models\Post; use Illuminate\Database\Eloquent\Factories\Factory; use Illuminate\Support\Str;
class PostFactory extends Factory { /** * The name of the factory's corresponding model. * * @var string */ protected $model = Post::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'title' => $this->faker->unique()->sentence,
'body' => $this->faker->paragraph,
];
}
}
going into DatabaseSeeder.php and adding \App\Models\Post::factory(10)->create(); then running php artisan db:seed works just fine.
the user factory works just fine, I can not for the life of me figure out why the post factory does not work. Thanks
Level 1
2 likes
Please or to participate in this conversation.