| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- <?php
- namespace App\Console\Commands;
- use Illuminate\Console\Command;
- use Illuminate\Support\Facades\Redis;
- // 清空用户相关数据表
- class TruncateUserDataCommand extends Command
- {
- /**
- * The name and signature of the console command.
- *
- * @var string
- */
- protected $signature = 'truncate:users';
- /**
- * The console command description.
- *
- * @var string
- */
- protected $description = '清空用户相关数据';
- /**
- * Create a new command instance.
- *
- * @return void
- */
- public function __construct()
- {
- parent::__construct();
- }
- /**
- * Execute the console command.
- *
- * @return int
- */
- public function handle()
- {
- // 临时测试
- // $o = \App\Models\Account::where("username","kailuo99")->first();
- // $o->delete();
- // \App\Models\FittingRoom::where("account_id", $o->id)->delete();
- //
- \DB::table('accounts')->truncate();
- \DB::table('box_records')->truncate();
- \DB::table('coupon_records')->truncate();
- \DB::table('gift_records')->truncate();
- \DB::table('pack_records')->truncate();
- \DB::table('paster_records')->truncate();
- \DB::table('fitting_rooms')->truncate();
- // 清空redis
- // Redis::flushdb();
- //
- return 0;
- }
- }
|