TruncateUserDataCommand.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace App\Console\Commands;
  3. use Illuminate\Console\Command;
  4. use Illuminate\Support\Facades\Redis;
  5. // 清空用户相关数据表
  6. class TruncateUserDataCommand extends Command
  7. {
  8. /**
  9. * The name and signature of the console command.
  10. *
  11. * @var string
  12. */
  13. protected $signature = 'truncate:users';
  14. /**
  15. * The console command description.
  16. *
  17. * @var string
  18. */
  19. protected $description = '清空用户相关数据';
  20. /**
  21. * Create a new command instance.
  22. *
  23. * @return void
  24. */
  25. public function __construct()
  26. {
  27. parent::__construct();
  28. }
  29. /**
  30. * Execute the console command.
  31. *
  32. * @return int
  33. */
  34. public function handle()
  35. {
  36. // 临时测试
  37. // $o = \App\Models\Account::where("username","kailuo99")->first();
  38. // $o->delete();
  39. // \App\Models\FittingRoom::where("account_id", $o->id)->delete();
  40. //
  41. \DB::table('accounts')->truncate();
  42. \DB::table('box_records')->truncate();
  43. \DB::table('coupon_records')->truncate();
  44. \DB::table('gift_records')->truncate();
  45. \DB::table('pack_records')->truncate();
  46. \DB::table('paster_records')->truncate();
  47. \DB::table('fitting_rooms')->truncate();
  48. // 清空redis
  49. // Redis::flushdb();
  50. //
  51. return 0;
  52. }
  53. }