<?php

namespace App\Http\Controllers\Channel\Finance;

use App\Http\Controllers\Channel\BaseController as ChannelBaseController;
use Illuminate\Http\Request;

class BaseController extends ChannelBaseController
{
    /**
     * 检测参数有没有为空的
     * @param Request $request
     * @param $params
     * @return bool
     */
    public static function checkParamValueEmpty(Request $request, $params) {
        $isCheck = false;
        foreach ($params as $keyName) {
            $value = $request->has($keyName) ? $request->input($keyName) : '';
            if(empty($value)) {
                $isCheck = true;
            }
        }
        return $isCheck;
    }

    /**
     * 检测参数有没有不是数字的
     * @param Request $request
     * @param $params
     * @return bool
     */
    public static function checkParamValueNumber(Request $request, $params) {
        $isCheck = false;
        foreach ($params as $keyName) {
            $value = $request->has($keyName) ? $request->input($keyName) : '';
            if(!is_numeric($value)) {
                $isCheck = true;
            }
        }
        return $isCheck;
    }

    /**
     * 获取今天最大时间
     * @param string $dayTime
     * @return mixed
     */
    public static function getMaxDay($dayTime = '') {
        if(!empty($dayTime) && (strlen(trim($dayTime)) == 8 || strlen(trim($dayTime)) == 10)) {
            $dayTime = $dayTime." 23:59:59";
        }
        return $dayTime;
    }
}