gpt4 book ai didi

php - 类 tableseeder 不存在(虽然确实存在):S

转载 作者:可可西里 更新时间:2023-10-31 23:03:22 24 4
gpt4 key购买 nike

尝试使用 laravel 5.4 迁移和播种我的数据库时出现此错误

[ReflectionException] Class PostTagTableSeeder does not exist

事实上文件确实存在并带有正确的类名

seeds/PostTagTableSeeder.php

<?php

use Illuminate\Database\Seeder;
use App\Tag;
use App\Post;

class PostTagTableSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Model::unguard();
//DB::table('post_tag')->delete();

$tag1 = Tag::find(1);
$tag2 = Tag::find(2);
$tag3 = Tag::find(3);
$tag4 = Tag::find(4);
$post1 = Post::find(1);
$post2 = Post::find(2);
$post3 = Post::find(3);
$post4 = Post::find(4);
$post5 = Post::find(5);
$post6 = Post::find(6);
$post7 = Post::find(7);
$post8 = Post::find(8);
$post9 = Post::find(9);
$post10 = Post::find(10);
$post11 = Post::find(11);
$post12 = Post::find(12);
$post13 = Post::find(13);
$post14 = Post::find(14);
$post15 = Post::find(15);

$post1->tags()->attach([$tag1->id,$tag2->id,$tag3->id]);
$post2->tags()->attach([$tag2->id,$tag4->id]);
$post3->tags()->attach([$tag2->id,$tag3->id,$tag4->id]);
$post4->tags()->attach([$tag4->id]);
$post5->tags()->attach([$tag2->id]);
$post6->tags()->attach([$tag2->id]);
$post7->tags()->attach([$tag2->id]);
$post8->tags()->attach([$tag1->id,$tag4->id]);
$post9->tags()->attach([$tag1->id,$tag4->id]);
$post10->tags()->attach([$tag3->id]);
$post11->tags()->attach([$tag1->id]);
$post12->tags()->attach([$tag1->id]);
$post13->tags()->attach([$tag3->id]);
$post14->tags()->attach([$tag1->id,$tag2->id,$tag4->id]);
$post15->tags()->attach([$tag1->id,$tag2->id,$tag4->id]);
}
}

seeds/DatabaseSeeder.php

<?php

use Illuminate\Database\Seeder;

class DatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$this->call(UsersTableSeeder::class);
$this->call(AdminsTableSeeder::class);
$this->call(PostsTableSeeder::class);
$this->call(CategoriesTableSeeder::class);
$this->call(CategoryPostTableSeeder::class);
$this->call(TagsTableSeeder::class);
$this->call(PostTagTableSeeder::class);
$this->call(CommentsTableSeeder::class);
}
}

我一直在努力解决这个问题,但我仍然遇到同样的错误 enter image description here

最佳答案

有同样的问题并且正在运行

composer dump-autoload

按照 Vape 和 Oliver 上面的建议解决了这个问题。然后重新运行迁移

php artisan migrate:refresh --seed

或播种机

php artisan db:seed

它会像魅力一样运行。

关于php - 类 tableseeder 不存在(虽然确实存在):S,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44028608/

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