gpt4 book ai didi

php - 当我尝试为我的数据库播种时出现错误

转载 作者:可可西里 更新时间:2023-11-01 00:55:03 25 4
gpt4 key购买 nike

当我尝试使用 faker 在 laravel 5.4 中播种我的数据库时出现错误

use Illuminate\Database\Seeder;
use app\PostModell;
class postcarseeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{

// Let's truncate our existing records to start from scratch.
PostModell::truncate();

$faker = \Faker\Factory::create();

// And now, let's create a few articles in our database:
for ($i = 0; $i < 50; $i++) {
PostModell::create([
'title' => $faker->sentence,
'body' => $faker->paragraph,
]);
}
}

上面是我的播种器类,它使用以下命令调用我的 DatabaseSeeder.php $this->call(postcarseeder::class); 这样我就可以运行 php artisan db :种子

我得到的错误是 enter image description here

enter image description here

最佳答案

你应该使用完整的命名空间:

App\PostModell

或者将其添加到播种器类的顶部:

use App\PostModell;

关于php - 当我尝试为我的数据库播种时出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48383441/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com