/** * search double payment * * @param int $id current payment id * @param string $term * @param string $order * @param string $amount * @param string|array $type * @param string|array $status * * @return PaymentModel|null */ public static function findDouble($id, $term, $order, $amount, $type = null, $status = null) { $payment = PaymentModel::whereTerm($term)->whereOrder($order)->whereAmount($amount)->where('id', '!=', $id); if (!is_array($type)) { $type = (array) $type; } if (!is_array($status)) { $status = (array) $status; } if ($status) { $payment->whereIn('status', $status); } if ($type) { $payment->whereIn('type', $type); } // last hour $payment->whereRaw('created_at >= DATE_SUB(NOW(), INTERVAL 1 HOUR)'); $payment = $payment->first(); return $payment; }