Created
November 18, 2012 03:37
-
-
Save JeremiahTolbert/4103342 to your computer and use it in GitHub Desktop.
Laravel Ajax Filter for Controllers
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 | |
//This part would be included in the controller itself like so: | |
class Articles_Controller extends Controller { | |
public function __construct() { | |
parent::__construct(); | |
$this->filter('before', 'csrf')->on('post'); | |
$this->filter('before', 'ajax')->only(array('index', 'show', 'update')); | |
} | |
} | |
//This part would go in the route.php | |
Route::filter('ajax', function() { | |
if (Request::ajax() === false) | |
return Response::error('500'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment