<?php
 namespace TechSoft\Laravel\Agent; use Illuminate\Support\Facades\Log; use TechOnline\Laravel\Dao\ModelUtil; class AppDeviceUtil { public static function update($clientPlatform, $clientId, $update = []) { if (empty($clientPlatform) || empty($clientId)) { return; } $where = [ 'clientPlatform' => $clientPlatform, 'clientId' => $clientId, ]; $update['lastActive'] = date('Y-m-d H:i:s'); if (ModelUtil::exists('app_device', $where)) { ModelUtil::update('app_device', $where, $update); } else { ModelUtil::insert('app_device', array_merge($where, $update)); } } public static function getLatestActive($where) { $all = ModelUtil::model('app_device')->where($where)->limit(1)->orderBy('lastActive', 'desc')->get()->toArray(); if (empty($all)) { return null; } return $all[0]; } }