123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- <?php
- namespace App\Console\Commands;
- use Illuminate\Console\Command;
- use Illuminate\Support\Facades\DB;
- class ClearDataCommand extends Command
- {
- /**
- * The name and signature of the console command.
- *
- * @var string
- */
- protected $signature = 'clear:data';
- /**
- * 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 mixed
- */
- public function handle()
- {
- if (!$this->confirm("您确定要清空数据吗?")) {
- return true;
- }
- DB::table('advertisements')->truncate();
- DB::table('announcements')->truncate();
- DB::table('card_riding_orders')->truncate();
- DB::table('card_riding_use_logs')->truncate();
- DB::table('card_riding_user_bags')->truncate();
- DB::table('user_phone_details')->truncate();
- DB::table('users')->truncate();
- DB::table('auth')->truncate();
- DB::table('refund_logs')->truncate();
- DB::table('recharge_orders')->truncate();
- DB::table('questions')->truncate();
- DB::table('parkings')->truncate();
- DB::table('orders')->truncate();
- DB::table('rent_orders')->truncate();
- DB::table('rent_order_bike_operates')->truncate();
- DB::table('order_bike_operates')->truncate();
- DB::table('deposit_orders')->truncate();
- DB::table('location_logs')->truncate();
- DB::table('bike_troubles')->truncate();
- DB::table('statistics')->truncate();
- DB::table('troubles')->truncate();
- DB::table('work_orders')->truncate();
- DB::table('worker_bike_operates')->truncate();
- DB::table('wallet_logs')->truncate();
- DB::table('bikes')->truncate();
- DB::table('box_binding')->truncate();
- DB::table('workers')->truncate();
- DB::table('warning_logs')->truncate();
- DB::connection('mongodb')->collection('location_logs')->delete();
- DB::table('area_settings')->truncate();
- DB::table('areas')->truncate();
- DB::table('telescope_entries')->delete();
- DB::table('apply_parkings')->truncate();
- DB::table('card_riding')->truncate();
- DB::table('card_riding_area')->truncate();
- DB::table('card_riding_orders')->truncate();
- DB::table('card_riding_use_logs')->truncate();
- DB::table('card_riding_user_bags')->truncate();
- DB::table('coupons')->truncate();
- DB::table('coupons_user_bags')->truncate();
- DB::table('deposit_card_orders')->truncate();
- DB::table('deposit_cards')->truncate();
- DB::table('form_ids')->truncate();
- DB::table('group_send_smss')->truncate();
- DB::table('h5')->truncate();
- DB::table('invite_new_users')->truncate();
- DB::table('invite_new_users_configs')->truncate();
- DB::table('invite_new_users_give_gift_logs')->truncate();
- DB::table('punishment_orders')->truncate();
- DB::table('recharge_configuration')->truncate();
- DB::table('refund_balance_orders')->truncate();
- DB::table('uploads')->truncate();
- if ($this->confirm('是否清除用户信息?', false)) {
- DB::table('admin_users')->truncate();
- //创建用户
- DB::table('admin_users')->insert([
- 'job_number' => '10001',
- 'name' => '超级管理员',
- 'account' => 'admin',
- 'phone' => '15225006562',
- 'password' => '$2y$10$Q8rl3Esl4Gjjp/GFTHa/MeWTdUq/PU15LnmlM7NXjwqKN5X30fGA6',
- 'type' => 1,
- 'pid' => 0,
- 'status' => 1,
- 'admin_id' => 0,
- 'area_id' => 0,
- 'is_login_app' => 1,
- ]);
- DB::table('admin_area')->truncate();
- DB::table('admin_area')->insert([
- 'admin_id' => 1,
- 'area_id' => 99999,
- ]);
- DB::table('admin_user_role')->truncate();
- DB::table('admin_user_role')->insert([
- 'user_id' => 1,
- 'role_id' => 1,
- ]);
- }
- $this->line('ok');
- }
- }
|