Looking to hire Laravel developers? Try LaraJobs

laravel-ajax-only-middleware maintained by penance316

Description
laravel middleware to allow ajax only calls
Author
Last update
2018/01/03 12:33 (dev-master)
License
Links
Downloads
6 439

Comments
comments powered by Disqus

Laravel Ajax Only Middleware

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']);