<?php

return [
    // API 配置
    'api' => [
        // API PREFIX
        'prefix' => env('API_PREFIX', 'api'),
    ],

    // GUZZLE 配置
    'guzzle' => [
        // Debugging
        'log_middleware_debug' => true,
        // 重试
        'retry_middleware_retries' => 2,

        'curl' => [
            CURLOPT_IPRESOLVE => CURL_IPRESOLVE_V4,
        ],

        'timeout' => 10.0, // 超时时间（秒）

        'http_errors' => false, // 是否抛出Http错误

        'verify' => true, // 关掉SSL认证（强烈不建议！！！）
    ],

    // 仓库层 配置
    'repository' => [
        'pagination' => [
            // Repository Pagination Limit Default
            'limit' => env('REPOSITORY_PAGINATION_LIMIT', 10),
        ],

        'cache' => [
            // 是否开启缓存
            'enabled' => env('REPOSITORY_CACHE', true),

            // 缓存时间
            'minutes' => env('REPOSITORY_CACHE_TIME', 30),

            // Cache Repository Instance of Illuminate\Contracts\Cache\Repository
            'repository' => 'cache',

            'params' => [
                // Skip Cache Params
                'skipCache' => 'skipCache'
            ],
        ],

        'criteria' => [
            // 设置 允许的搜索条件
            'acceptedConditions' => [
                '=',
                '<>',
                '>',
                '>=',
                '<=',
                '<',
                'like',
                'between',
                'in',
                'has',
            ],
            // 搜索标准
            'params' => [
                'search' => 'search',
                'searchFields' => 'searchFields',
                'filter' => 'filter',
                'orderBy' => 'orderBy',
                'sortedBy' => 'sortedBy',
                'with' => 'with',
                'searchJoin' => 'searchJoin',
                'trashed' => 'trashed',
            ],
            /*
            |
            | 请求参数示例
            |
            | - search:
            |   Ex:
            |    http://dipper.dev/users?search=John
            |    http://dipper.dev/users?search=name:John;email:john@gmail.com
            |
            | - searchFields:
            |   Ex:
            |    http://dipper.dev/?search=lorem&searchFields=name;email
            |    http://dipper.dev/?search=lorem&searchFields=name:like
            |    http://dipper.dev/?search=lorem&searchFields=name:like;email:=
            |
            | - filter:
            |   Ex:
            |   http://dipper.dev/?search=lorem&filter=id,name
            |
            | - orderBy:
            |   Ex:
            |   http://dipper.dev/?search=lorem&orderBy=id
            |
            | - sortedBy:
            |   Ex:
            |   http://dipper.dev/?search=lorem&orderBy=id&sortedBy=asc
            |   http://dipper.dev/?search=lorem&orderBy=id&sortedBy=desc
            |
            | - searchJoin: 搜索方法配置 (AND / OR), 默认为 AND
            |   EX:
            |   http://dipper.dev/?search=lorem&searchJoin=and
            |   http://dipper.dev/?search=lorem&searchJoin=or
            |
            */

            'dates' => ['created_at', 'updated_at', 'deleted_at'],
        ],
    ],

    // 全局ID配置
    'snowflake' => [
        'macheine_id' => env('SNOWFLAKE_MACHEINE_ID', 0),
        'sequence' => env('SNOWFLAKE_SEQUENCE', 0),
    ],

    // Debugger配置
    'debugger' => [
        // Requests Debugger
        'requests' => [
            'debug' => env('REQUESTS_DEBUG', false),
            'log_file' => 'debugger.log',
            'response_show_first' => '700',
            'token_show_first' => '80',
        ],
        // Queries Debugger Settings
        'queries' => [
            'debug' => env('QUERIES_DEBUG', false),
            'log_file' => 'debugger.log',
        ]
    ],
];
