You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
660 B

  1. <?php
  2. /** @var Factory $factory */
  3. use Carbon\Carbon;
  4. use App\Models\Transaction;
  5. use Faker\Generator as Faker;
  6. use Illuminate\Support\Facades\DB;
  7. $factory->define(Transaction::class, function (Faker $faker) {
  8. $business_user = DB::selectOne('select business_id, user_id from business_user where level = 4 order by rand() limit 1');
  9. return [
  10. 'user_id' => $business_user->user_id,
  11. 'business_id' => $business_user->business_id,
  12. 'amount' => random_int(1000, 9999),
  13. 'succeeded' => $faker->boolean(),
  14. 'options' => json_encode([]),
  15. 'created_at' => Carbon::now()->subMinutes(random_int(1, 1000)),
  16. ];
  17. });