penance316 / laravel-ajax-only-middleware
laravel middleware to allow ajax only calls
Installs: 5 700
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: >=5.4.0
This package is auto-updated.
Last update: 2024-11-09 23:43:29 UTC
README
Description
A small middleware that prevents routes being access unless via AJAX methods.
Install
composer require "penance316/laravel-ajax-only-middleware"
Register the middleware with you app in app/Http/Kernal.php
/**
* The application's route middleware.
*
* @var array
*/
protected $routeMiddleware = [
//... existing code
'ajax' => Penance316\Middleware\AjaxOnly::class,
];
}
Attach middleware to any routes you want to be accessible only via AJAX requests
// File: routes.php
get('someitem/{id}', ['middleware' => 'ajax', 'uses' => 'SomeController@show']);