我已经尝试了所有可能的方法,但我无法弄清楚我做错了什么。我正在尝试用虚拟数据加载我的数据库,但我一直得到未知的格式化程序“描述”。描述是我正在使用的变量之一。下面是我的工厂代码和我的播种机编码器use Faker\Generator as Faker;use Analytics\Blockgrant;$factory->define(Blockgrant::class, function (Faker $faker) { return [ 'description' => $faker->description, 'value' => $faker->value ];});<?phpuse Faker\Generator as Faker;use Universityobfanalytics\Blockgrantcomponents;$factory->define(Blockgrantcomponents::class, function (Faker $faker) { return [ 'blockgrants_id' => $faker->blockgrants_id, 'description' => $faker->description, 'percentage' => $faker->percentage, 'value' => $faker->value ];});<?phpuse Illuminate\Database\Seeder;use Analytics\Blockgrant;use Analytics\Blockgrantcomponents;class BlockgrantSeeder extends Seeder{ /** * Run the database seeds. * * @return void */ public function run() { factory(Blockgrant::class, 10)->create()->each(function ($blockgrant) { $blockgrant->blockgrantcomponents()->save(factory(Blockgrantcomponents::class)->create()); }); }}我正在使用一对一hasOne和belongsTo关系有人可以通过告诉我我做错了什么来提供帮助。
- 2 回答
- 0 关注
- 100 浏览
添加回答
举报
0/150
提交
取消