Skip to content

Commit

Permalink
feat: localize
Browse files Browse the repository at this point in the history
  • Loading branch information
jiannei committed Dec 24, 2021
1 parent b3ccfc8 commit 5193800
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,20 @@ public function ok(string $message = '', int $code = 200, array $headers = [], i
return $this->success([], $message, $code, $headers, $option);
}

/**
* Alias of the successful method, no need to specify the message and data parameters.
* You can use ResponseCodeEnum to localize the message.
*
* @param int $code
* @param array $headers
* @param int $option
* @return JsonResponse|JsonResource
*/
public function localize(int $code = 200, array $headers = [], int $option = 0)
{
return $this->ok('', $code, $headers, $option);
}

/**
* Return a 400 bad request error.
*
Expand Down
1 change: 1 addition & 0 deletions src/Support/Facades/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* @method static JsonResponse|JsonResource accepted($data = null, string $message = '', string $location = '')
* @method static JsonResponse|JsonResource created($data = null, string $message = '', string $location = '')
* @method static noContent(string $message = '')
* @method static JsonResponse|JsonResource localize(int $code = 200, array $headers = [], int $option = 0)
* @method static JsonResponse|JsonResource ok(string $message = '', int $code = 200, array $headers = [], int $option = 0)
* @method static JsonResponse|JsonResource success($data = null, string $message = '', int $code = 200, array $headers = [], int $option = 0)
* @method static void errorBadRequest(?string $message = '')
Expand Down

0 comments on commit 5193800

Please sign in to comment.