ShaunR Posted December 4, 2017 Share Posted December 4, 2017 I'm looking for a simple way to get the worst severity from the template variable $ClientAlerts. Any idea's on how I can do this without a looping over the collection and comparing each severity with the others? https://docs.whmcs.com/classes/7.4/WHMCS/User/Alert.html https://laravel.com/docs/5.2/collections Link to comment Share on other sites More sharing options...
brian! Posted December 6, 2017 Share Posted December 6, 2017 On 12/4/2017 at 18:35, ShaunR said: I'm looking for a simple way to get the worst severity from the template variable $ClientAlerts. Any idea's on how I can do this without a looping over the collection and comparing each severity with the others? I can't think of a simple way other than looping... if WHMCS had designed the severity values as numbers (0=danger, 1=warning, 2=info etc) rather than strings, then you could just have sorted the collection by the value... but they didn't, and so sorting alphabetically would just give you an order of : DANGER -> INFO -> WARNING (or the reverse) - neither option would give you the result that you are looking for. ... and I think that v7.4 uses v5.4 of the Laravel docs rather than 5.2 - but if i'm wrong on that, hopefully one of the WHMCS guys will correct me. Link to comment Share on other sites More sharing options...
ShaunR Posted December 6, 2017 Author Share Posted December 6, 2017 WHMCS can you guys shed some light on if any type of sorting is done to $ClientAlerts? I'm curious as to why alerts with a higher severity are not being shown first. Link to comment Share on other sites More sharing options...
brian! Posted December 6, 2017 Share Posted December 6, 2017 3 hours ago, ShaunR said: I'm curious as to why alerts with a higher severity are not being shown first. every example i've ever seen in the client area has been sorted alphabetically ascending by severity - so danger, info, warning. Link to comment Share on other sites More sharing options...
ShaunR Posted December 8, 2017 Author Share Posted December 8, 2017 Anybody else who would like to see ClientAlerts sorted by severity, showing the worst first, please upvote and comment on this request... https://requests.whmcs.com/topic/sort-template-variable-clientalerts-by-severity Link to comment Share on other sites More sharing options...
Recommended Posts