Created
January 6, 2022 21:27
-
-
Save Braunson/93e67cb9592127d835f0da9abb4fdc8c to your computer and use it in GitHub Desktop.
Detect if a request is from Livewire or not, useful when you have middleware that needs to ignore Livewire requests. Drop this in the boot method.
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 | |
// Detect requests from Livewire | |
Request::macro('isFromLivewire', function() { | |
return $this->headers->has('x-livewire'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Very useful, thanks!