Last active
January 20, 2021 02:18
-
-
Save bolechen/22aa3ce56522bcf34021d813e3985cb2 to your computer and use it in GitHub Desktop.
Add isWecht for Laravel Request helper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// 判断是否微信内访问. | |
Request::macro('isWechat', function (): bool { | |
if (app()->environment(['local', 'testing'])) { | |
return true; | |
} | |
/** @var Request $request */ | |
$request = $this; | |
return false !== strpos($request->userAgent(), 'MicroMessenger'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment