ホーム > Laravel > How to Determine Devices like Smartphones in Laravel
Laravel

How to Determine Devices like Smartphones in Laravel

Thank you for your continued support.
This article contains advertisements that help fund our operations.

⇨ Click here for the table of contents for Laravel articles

This article summarizes how to determine devices like smartphones in Laravel

Laravel Framework 8.83.8

Conclusion

In the Controller,

public function index(Request $request){
  $userAgent = $request->header('User-Agent');
  dd($userAgent);//Check the content
}

You can retrieve it by writing like this.

Similarly in Middleware

    public function handle($request, Closure $next)
    {
        $userAgent = $request->headers->get('user-agent');
        dd($userAgent);//Check the content
    }

You can retrieve it in this way.

Summary

That's all.

I hope it will be helpful for someone.

For feedback or complaints, please contact me via Twitter DM.

That's all!

Popular Posts

Deploying PHP7.4 + Laravel6 Project to AWS EC2

Implementing Breadcrumbs in Laravel with laravel-breadcrumbs

Please Provide Feedback
We would appreciate your feedback on this article. Feel free to leave a comment on any relevant YouTube video or reach out through the contact form. Thank you!