Laravel 播种不适用于克隆的存储库

Laravel seeding not working on cloned repository

使用 laravel 模型工厂的数据库播种在我的本地(原始)repo/laravel 项目文件上完美运行, 但是当我从 github 克隆遥控器时,播种会抛出此错误:

Column n ot found: 1054 Unknown column 'hr' in 'field list' (SQL: insert in to categories (slug, hr, de, updated_at, created_at) v alues (CATEGORY-1, Title for category-1 on hr language, Title for category-1 on de language, 2018-07-09 11:19:45, 2018-07-09 11:19:4 5))

迁移工作没有问题,在本地和克隆的 repo 上,我使用 Laravel Translatable 包。 字段 hr 和 de 是语言环境

我试过推送到远程,但它说一切都是最新的,我也试过手动将播种机和工厂从本地复制到 remote/cloned 文件夹,但它仍然没有没用。

(以下文件在原始和克隆的 repo 上是相同的)

数据库播种机:

public function run()
{
     $this->call([
        LanguagesTableSeeder::class, //works
        CategoriesTableSeeder::class, //error
        MealsTableSeeder::class  //error
     ]);
}

类别播种器:

public function run()
{
    factory(App\Category::class, 5)->create();
}

类别工厂:

use Faker\Generator as Faker;

使用App\Language;

$factory->define(App\Category::class, function (Faker $faker) {

 static $counter = 1;
 $locales = Language::pluck('lang');
 $data = array('slug' => 'CATEGORY-'.$counter);

 foreach ($locales as $locale) {
    $data[$locale] = [
        'title' => 'Title for category-' .$counter. ' on '. $locale . ' language'
    ];
 }
 $counter++;


return $data;
});

更新:

语言表播种器:

public function run()
{
    if(!App\Language::count()) {

        $defaultLanguages = array('hr','en','de');

        foreach ($defaultLanguages as $language) {
            App\Language::create([
                'lang' => $language
            ]);
        }
    }
}

类别迁移:

public function up()
{
    Schema::create('categories', function (Blueprint $table) {
        $table->increments('id');
        $table->string('slug');
        $table->timestamps();
    });

     Schema::create('category_translations', function (Blueprint $table) {
        $table->increments('id');
        $table->integer('category_id')->unsigned();
        $table->string('locale')->index();
        $table->string('title');
        $table->unique(['category_id','locale']);
        $table->foreign('category_id')->references('id')->on('categories')->onDelete('cascade');
    });
}

Repository link

好的,几个小时后或尝试了所有方法后,我找到了解决方案。

克隆存储库中的供应商目录有问题。

当我从 .gitignore 中删除供应商时,它突然开始工作,而不是使用 composer install 在克隆中创建供应商,我只是将完整的原始供应商上传到 github。