本文整理匯總了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]);
});
});