created_at)) { $companyGameBind->created_at = date('Y-m-d H:i:s'); } if (empty($companyGameBind->updated_at)) { $companyGameBind->updated_at = date('Y-m-d H:i:s'); } }); // 更新前自动设置更新时间 self::beforeUpdate(function ($companyGameBind) { $companyGameBind->updated_at = date('Y-m-d H:i:s'); }); } /** * 获取游戏数量 */ public function getGameCountAttr($value, $data) { if (empty($data['game_ids'])) { return 0; } $gameIds = explode(',', $data['game_ids']); return count(array_filter($gameIds)); } }