penance316/laravel-ajax-only-middleware

laravel middleware to allow ajax only calls

v1.0 2018-01-03 11:33 UTC

This package is auto-updated.

Last update: 2024-03-09 21:56:34 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']);