当工匠 -

时间:2018-01-16 09:34:31

标签: laravel

我手动在文件夹数据库/种子中添加了CategoriesSeeder.php:

<?php

use Illuminate\Database\Seeder;
use App\Category;

class CategoriesSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $category = new Category();
        $category->name = 'kategoria1';
        $category->save();

        $category = new Category();
        $category->name = 'kategoria2';
        $category->save();

        $category = new Category();
        $category->name = 'kategoria3';
        $category->save();
    }
}

ad我在DatabaseSeeder.php文件中提到过它

<?php

use Illuminate\Database\Seeder;

class DatabaseSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $this->call(CategoriesSeeder::class);

    }
}
输入后

 λ php artisan migrate:refresh --seed

我收到了回复:

  [ReflectionException]
  Class CategoriesSeeder does not exist

我做错了什么?我知道我应该添加命令

λ php artisan make:seeder CategoriesSeeder

但如何手动完成?

0 个答案:

没有答案