本文整理匯總了PHP中App\Http\Controllers\Controller::callAction方法的典型用法代碼示例。如果您正苦於以下問題:PHP Controller::callAction方法的具體用法?PHP Controller::callAction怎麽用?PHP Controller::callAction使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類App\Http\Controllers\Controller
的用法示例。
在下文中一共展示了Controller::callAction方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: callAction
public function callAction($method, $parameters)
{
// Only admin can access this controller
$user = Auth::user();
if (!$user->is_admin) {
return app()->abort(403);
}
return parent::callAction($method, $parameters);
}
示例2: callAction
/**
* Catch not found exceptions
*
* @param string $method
* @param array $parameters
* @return \Illuminate\Http\JsonResponse|\Symfony\Component\HttpFoundation\Response
*/
public function callAction($method, $parameters)
{
try {
return parent::callAction($method, $parameters);
} catch (ChildNodeNotFound $e) {
return Response::json(['Child node not found'], \Illuminate\Http\Response::HTTP_NOT_FOUND);
} catch (ParentNodeNotFound $e) {
return Response::json(['Parent node not found'], \Illuminate\Http\Response::HTTP_NOT_FOUND);
} catch (ModelNotFoundException $e) {
return Response::json('Node not found', \Illuminate\Http\Response::HTTP_NOT_FOUND);
}
}