本文整理汇总了PHP中JsonHelper::getSuccessResponse方法的典型用法代码示例。如果您正苦于以下问题:PHP JsonHelper::getSuccessResponse方法的具体用法?PHP JsonHelper::getSuccessResponse怎么用?PHP JsonHelper::getSuccessResponse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JsonHelper
的用法示例。
在下文中一共展示了JsonHelper::getSuccessResponse方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$photos = Photo::all();
return response()->json(\JsonHelper::getSuccessResponse($photos));
}
示例2: function
// return ['data' => 'This has come from a dedicated API subdomain with restricted access.'];
// });
/*
|--------------------------------------------------------------------------
| Dev
|--------------------------------------------------------------------------
*/
Route::group(array('prefix' => 'dev'), function () {
// Facebook Login
Route::get('fb-login', array('as' => 'fb-login', 'uses' => 'Dev\\AuthController@fbLogin'));
});
Route::resource('user', 'UserController');
Route::resource('photo', 'PhotoController');
Route::get('signup', function () {
$credentials = Input::only('email', 'password');
try {
$user = User::create($credentials);
} catch (Exception $e) {
return Response::json(['error' => 'User already exists.'], HttpResponse::HTTP_CONFLICT);
}
$token = JWTAuth::fromUser($user);
return Response::json(compact('token'));
});
Route::get('signin', function () {
$credentials = Input::only('email', 'password');
if (!($token = JWTAuth::attempt($credentials))) {
return Response::json(false, HttpResponse::HTTP_UNAUTHORIZED);
}
return JsonHelper::getSuccessResponse(['token' => $token]);
});
});