12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- <?php
- namespace App\Console\Commands;
- use App\Repositories\Models\Base\Admin;
- use Illuminate\Console\Command;
- use Illuminate\Support\Facades\DB;
- use Illuminate\Support\Facades\Hash;
- /**
- * Class PresenterCommand
- * @package Prettus\Repository\Generators\Commands
- * @author Anderson Andrade <contato@andersonandra.de>
- */
- 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');
- }
- }
|