Have you considered a package such as ua-parser/uap-php?
I'm not sure you can get the device explicitly, but it will do a lot of the heavy parsing for you and give you access to more granular information from the user agent.
Sign in to participate in this thread!