1

I am following this laracast tutorial and as I key in this command in tinker:

factory('App\Flyer')->make();

I get this error:

PHP Fatal error: Call to undefined function factory() in eval()'d cod1

My php version locally installed is 5.4.38

So how do I get rid of this error?

PS: I want to avoid upgrading laravel at this stage as it would require me to update my php as well. So looking for some other workaround.

Community
  • 1
  • 1
rahulserver
  • 10,411
  • 24
  • 90
  • 164

1 Answers1

1

Model factories were added in Laravel 5.1 so it's obvious it won't work in Laravel 5.0.*

Reference: https://laravel.com/docs/5.2/releases#laravel-5.1

Marcin Nabiałek
  • 109,655
  • 42
  • 258
  • 291
  • So is there any way otherwise to somehow seed the database with random data in 5.0.x? – rahulserver Dec 27 '15 at 15:51
  • @rahulserver You could use the [Faker](https://github.com/fzaninotto/Faker) library directly (Laravel Model Factories use it behind the scenes). [This article](http://laraveldaily.com/generating-fake-seeds-data-with-faker-package/) explains how you can use it. – Bogdan Dec 27 '15 at 16:37
  • @rahulserver As Bogdan said, you can use [Faker library ](https://github.com/fzaninotto/Faker#basic-usage) which is used in Laravel 5.1 for factories – Marcin Nabiałek Dec 27 '15 at 17:12