{"templateId":"markdown","versions":[{"version":"9.0","label":"9.0","link":"/classes/whmcs/user/adminlog","default":true,"active":false,"folderId":"9d7dc099"},{"version":"8.13","label":"8.13","link":"/classes/8.13/whmcs/user/adminlog","default":false,"active":false,"folderId":"9d7dc099"}],"sharedDataIds":{"sidebar":"sidebar-classes/@8.13/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"type":"markdown"},"seo":{"title":"WHMCS\\User\\AdminLog","description":"Developer documentation for the WHMCS API — the","llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"whmcsuseradminlog","__idx":0},"children":["WHMCS\\User\\AdminLog"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Class"]}," · extends ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["AbstractModel"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["An administrative user login"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Each log entry in this table represents a single login session for an"," ","administrative user."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"constants","__idx":1},"children":["Constants"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Name"},"children":["Name"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Description"},"children":["Description"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ONLINE_WINDOW_MINUTES"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["The number of minutes since a visit within which an admin user is still considered to be online."]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"properties","__idx":2},"children":["Properties"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Type"},"children":["Type"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Name"},"children":["Name"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Description"},"children":["Description"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["``"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["$timestamps"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["``"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["$unique"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"methods","__idx":3},"children":["Methods"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"getonlinecutoff","__idx":4},"children":["getOnlineCutOff"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"php","header":{"controls":{"copy":{}}},"source":"public static function getOnlineCutOff(): string\n","lang":"php"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The time before which a visit no longer counts as being online."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Deliberately evaluated in PHP rather than with the database's NOW(),"," ","because every lastvisit value is written by PHP: update_query() and"," ","insert_query() expand \"now()\" to date('YmdHis') rather than passing it"," ","to the database. Comparing PHP written values against the database clock"," ","would make admin users permanently online, or permanently offline,"," ","wherever the two time zones differ."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Returns"]}," ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["string"]}," — A \"Y-m-d H:i:s\" time."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"admin","__idx":5},"children":["admin"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"php","header":{"controls":{"copy":{}}},"source":"public function admin()\n","lang":"php"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["An admin log entry belongs to an admin user."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Returns"]}," ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["\\Illuminate\\Database\\Eloquent\\Relations\\belongsTo"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"scopeonline","__idx":6},"children":["scopeOnline"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"php","header":{"controls":{"copy":{}}},"source":"public function scopeOnline($query)\n","lang":"php"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Retrieve the most recent open session of every admin user who is online."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Selects one deterministic row per admin user - the highest id - rather"," ","than grouping the outer query, which under a permissive sql_mode returns"," ","an arbitrary row from each group and under ONLY_FULL_GROUP_BY errors."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The open session constraint is repeated on the outer query deliberately."," ","MySQL materialises this IN rather than rewriting it into a semijoin, so"," ","without it the outer query carries no predicate and scans the whole of a"," ","table that is never pruned. Repeating it restores an index range scan,"," ","and cannot change the result set: every id the subquery yields belongs"," ","to a row that already satisfies the constraint."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Parameters"]}]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Type"},"children":["Type"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Name"},"children":["Name"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Description"},"children":["Description"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["\\Illuminate\\Database\\Eloquent\\Builder"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["$query"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[]}]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Returns"]}," ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["\\Illuminate\\Database\\Eloquent\\Builder"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"constraintoopensessions","__idx":7},"children":["constrainToOpenSessions"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"php","header":{"controls":{"copy":{}}},"source":"public static function constrainToOpenSessions($query)\n","lang":"php"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Narrow a tbladminlog query to the sessions that are still open, meaning"," ","visited inside the online window and not yet logged out."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Held here so that the scopes on this model and the staff presence"," ","repository agree on the window and on the zero date standing in for"," ","\"still logged in\". It is not the only place that knowledge lives: the"," ","legacy admin log screen and the GetStaffOnline and GetStats endpoints"," ","still spell the zero date out themselves, in three different literals."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Parameters"]}]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Type"},"children":["Type"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Name"},"children":["Name"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Description"},"children":["Description"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["\\Illuminate\\Database\\Query\\Builder|\\Illuminate\\Database\\Eloquent\\Builder"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["$query"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[]}]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Returns"]}," ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["\\Illuminate\\Database\\Query\\Builder\\|\\Illuminate\\Database\\Eloquent\\Builder"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"scopeoffline","__idx":8},"children":["scopeOffline"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"php","header":{"controls":{"copy":{}}},"source":"public function scopeOffline($query)\n","lang":"php"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Retrieve the log entries of every admin user who is not currently online."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Parameters"]}]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Type"},"children":["Type"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Name"},"children":["Name"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Description"},"children":["Description"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["\\Illuminate\\Database\\Eloquent\\Builder"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["$query"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[]}]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Returns"]}," ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["\\Illuminate\\Database\\Eloquent\\Builder"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"getlastvisitformattedattribute","__idx":9},"children":["getLastVisitFormattedAttribute"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"php","header":{"controls":{"copy":{}}},"source":"public function getLastVisitFormattedAttribute(): string\n","lang":"php"},"children":[]}]},"headings":[{"value":"WHMCS\\User\\AdminLog","id":"whmcsuseradminlog","depth":1},{"value":"Constants","id":"constants","depth":2},{"value":"Properties","id":"properties","depth":2},{"value":"Methods","id":"methods","depth":2},{"value":"getOnlineCutOff","id":"getonlinecutoff","depth":3},{"value":"admin","id":"admin","depth":3},{"value":"scopeOnline","id":"scopeonline","depth":3},{"value":"constrainToOpenSessions","id":"constraintoopensessions","depth":3},{"value":"scopeOffline","id":"scopeoffline","depth":3},{"value":"getLastVisitFormattedAttribute","id":"getlastvisitformattedattribute","depth":3}],"frontmatter":{"title":"WHMCS\\User\\AdminLog","seo":{"title":"WHMCS\\User\\AdminLog"}},"lastModified":"2026-10-21T18:20:53.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/classes/9.1/whmcs/user/adminlog","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}