<?php

namespace App\Admin\Controllers;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Modules\User\Models\Identity;
use Modules\User\Traits\RankDataTrait;
use Modules\User\Traits\WechatTrait;

class TestController extends Controller
{
    use WechatTrait, RankDataTrait;

    public function index()
    {
        $identities = Identity::all();
        dd($identities->toArray());
    }


    /**
     * Notes: 清空数据表的操作，为了测试用的
     *
     * @Author: <C.Jason>
     * @Date  : 2020/11/23 4:54 下午
     */
    public function truncate(Request $request)
    {
        $name    = $request->name;
        $is_test = config('app.is_test');
        dump('is_test'.$is_test);

        if ($name != 'skyxu') {
            dd('name不对');
        }

        if (! $is_test) {
            dd('不是测试环境');
        }

        $tables = [
            'admin_operation_log',
            'area_stocks',
            'area_codes',
            'area_clerks',
            'favorites',
            'cms_logs',
            'failed_jobs',
            'jobs',
            'linker_relations',
            'linkers',
            'mall_addresses',
            'mall_order_expresses',
            'mall_order_items',
            'mall_orders',
            'mall_carts',
            'mall_refund_items',
            'mall_refund_logs',
            'mall_refunds',
            'mall_refund_expresses',
            'payment_refunds',
            'payments',
            'user_account_logs',
            'user_accounts',
            'user_identity',
            'user_identity_logs',
            'user_identity_coupons',
            'user_infos',
            'user_invites',
            'user_logs',
            'user_orders',
            'user_perves',
            'user_relations',
            'user_sign_logs',
            'user_signs',
            'user_sms',
            'user_stock_logs',
            'user_stocks',
            'user_subscribes',
            'user_wechat_apps',
            'user_wechat_minis',
            'user_wechat_officials',
            'user_wechats',
            'users',
            'personal_access_tokens',
            'subscriptions',
            'task_logs',
            'task_users',
            'versions',
            'wechat_offiaccount_event_logs',
            'personal_access_tokens',
        ];
        foreach ($tables as $table) {
            DB::table($table)->truncate();
        }
        dd('清理成功');
    }

}

