NotificationSeeder.php 788 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. use Illuminate\Database\Seeder;
  3. class NotificationSeeder extends Seeder
  4. {
  5. /**
  6. * Run the database seeds.
  7. *
  8. * @return void
  9. */
  10. public function run()
  11. {
  12. $user = \App\User::first();
  13. $order = \App\Models\Order::first();
  14. \App\Models\Notification::truncate();
  15. $total = 100;
  16. for($i = 0; $i < $total; ++$i) {
  17. $type = mt_rand(1, 2);
  18. $status = $type == 1 ? mt_rand(1, 5) : mt_rand(1, 7);
  19. $is_read = mt_rand(1, 2);
  20. \App\Models\Notification::create([
  21. 'user_id' => $user->id,
  22. 'order_id' => $order->id,
  23. 'type' => $type,
  24. 'status' => $status,
  25. 'is_read' => $is_read
  26. ]);
  27. }
  28. }
  29. }