*/ class TestCommand extends Command { /** * The name of command. * * @var string */ protected $name = 'mead:test'; /** * The description of command. * * @var string */ protected $description = 'test'; /** * The type of class being generated. * * @var string */ protected $type = 'permission'; /** * Execute the command. * * @return void * @see fire() */ public function handle() { $this->line('ok'); } public function clearDB() { DB::statement('SET FOREIGN_KEY_CHECKS = 0'); // 禁用外键约束 DB::table('base_admins')->truncate(); DB::table('base_model_has_roles')->truncate(); DB::table('car_applies')->truncate(); DB::table('car_apply_logs')->truncate(); DB::table('car_bills')->truncate(); DB::table('car_grades')->truncate(); DB::table('car_order_logs')->truncate(); DB::table('car_orders')->truncate(); DB::table('car_shops')->truncate(); DB::table('base_users')->truncate(); DB::statement('SET FOREIGN_KEY_CHECKS = 1'); // 启用外键约束 $admin = Admin::query()->create([ 'username' => 'superadmin', 'name' => '超级管理员', 'mobile' => '15225006562', 'type' => '1', 'email' => '751066209@qq.com', 'password' => Hash::make('Q1w2e3r4!'), ]); $admin->syncRoles('admin'); } }