Add factory for Spending model
MODIFY
database/factories/ModelFactory.php
database/factories/ModelFactory.php
<?php
+use Faker\Generator;
use App\User;
+use App\Spending;
-$factory->define(User::class, function (Faker\Generator $faker) {
+$factory->define(User::class, function (Generator $faker) {
return [
'name' => $faker->name,
'email' => $faker->unique()->safeEmail,
@@ -10,3 +12,11 @@ $factory->define(User::class, function (Faker\Generator $faker) {
'remember_token' => str_random(10)
];
});
+
+$factory->define(Spending::class, function (Generator $faker) {
+ return [
+ 'happened_on' => $faker->dateTimeBetween('-50 days', 'now')->format('Y-m-d'),
+ 'description' => implode(' ', array_map('ucfirst', $faker->words(3))),
+ 'amount' => $faker->randomNumber(3)
+ ];
+});

Add factory for Spending model