尝试使用cmd在Laravel 5.6中播种时出现语法错误,意外的','

时间:2018-08-18 08:34:07

标签: php laravel laravel-migrations laravel-seeding

我正在尝试遵循有关在Windows中使用命令提示符的教程。它叫做Laravel Tutorial: Step by Step Guide to Building Your First Laravel Application,我被困在种子中:

use Illuminate\Database\Seeder;

class TestingTableSeeder extends Seeder
{
  public function run()
  {
    factory:(App\Testing::class, 5)->create();
  }
}

我已经尝试过其他有关堆栈溢出问题的解决方案,但无法修复错误。

2 个答案:

答案 0 :(得分:2)

应该是:

factory(App\Testing::class, 5)->create();

代替

factory:(App\Testing::class, 5)->create();

答案 1 :(得分:0)

您调用的工厂函数有误,请删除冒号(:),如下:

use Illuminate\Database\Seeder;

class TestingTableSeeder extends Seeder
{
    public function run()
    {
       factory(App\Testing::class, 5)->create();
    }
}