I have tried everything possible but I could not get to the bottom of what I am doing wrong. I am trying to load my database with dummy data but I keep get unknown formatter "description". Description is one of the variables I am using.
Below is my factory code and my seeder coder
use Faker\Generator as Faker;
use Analytics\Blockgrant;
$factory->define(Blockgrant::class, function (Faker $faker) {
return [
'description' => $faker->description,
'value' => $faker->value
];
});
<?php
use 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
];
});
<?php
use 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());
});
}
}
I am using a one to one hasOne
and belongsTo
relationship
Can somebody please assist by telling me what I am doing wrong.