22 lines
384 B
PHP
22 lines
384 B
PHP
<?php
|
|
|
|
namespace App\Traits;
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
/**
|
|
* 使得Controller可以過濾非Ajax的請求
|
|
*
|
|
* Trait PureAjaxMethodProtectable
|
|
* @package App\Traits
|
|
*/
|
|
trait PureAjaxMethodProtectable
|
|
{
|
|
// 非ajax請求則回應404
|
|
protected function protectFromNoneAjaxRequest(Request $request)
|
|
{
|
|
if(!$request->ajax()) abort(404);
|
|
return;
|
|
}
|
|
}
|