【问题标题】:Syntax error, unexpected ',' when trying to seed in Laravel 5.6 using cmd [closed]尝试使用 cmd 在 Laravel 5.6 中播种时出现语法错误,意外 ',' [关闭]
【发布时间】:2019-01-25 04:04:12
【问题描述】:

我正在尝试遵循有关在 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();
  }
}

我已经尝试过 Stack Overflow 上其他问题的解决方案,但我无法修复错误。

【问题讨论】:

  • 你遇到了什么错误?

标签: php laravel laravel-migrations laravel-seeding


【解决方案1】:

应该是:

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

而不是

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

【讨论】:

    【解决方案2】:

    你调用工厂函数错误,去掉后面的冒号(:)为:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-07
      • 1970-01-01
      • 2021-09-02
      • 2013-01-11
      • 2011-02-12
      相关资源
      最近更新 更多