PHP code example of penance316 / laravel-ajax-only-middleware

1. Go to this page and download the library: Download penance316/laravel-ajax-only-middleware library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

penance316 / laravel-ajax-only-middleware example snippets


  /**
    * The application's route middleware.
    *
    * @var array
    */
    protected $routeMiddleware = [
        //... existing code
        'ajax' => Penance316\Middleware\AjaxOnly::class,
    ];
}

// File: routes.php
get('someitem/{id}', ['middleware' => 'ajax', 'uses' => 'SomeController@show']);