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.
It can be because you are using PHPUnit\Framework\TestCase
instead of Tests\TestCase
in your test.
The faker library does not have the properties you are trying to access.
You can only make use of formatters like:
$faker->name
$faker->text
$faker->paragraphs()
$faker->sentences()
It would be best you go through the faker documentation to check the full list of available formatters here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With