Skip to content

Commit

Permalink
All paginated method make mixed
Browse files Browse the repository at this point in the history
  • Loading branch information
yetakchi committed Aug 1, 2024
1 parent 74fc312 commit 768e2d2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,5 @@ class UserRequest extends RestRequest {

# Foydali havolalar (Links)

- [Create Laravel package](https://laravel-news.com/building-your-own-laravel-packages)
- [Create Laravel package](https://laravel-news.com/building-your-own-laravel-packages)
- [Create package](https://medium.com/@prevailexcellent/how-i-created-my-third-laravel-package-step-by-step-guide-ad3fb0da5399)
11 changes: 5 additions & 6 deletions src/Responses/RestResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

namespace Ijodkor\ApiResponse\Responses;

use Illuminate\Contracts\Pagination\LengthAwarePaginator;
use Illuminate\Http\JsonResponse;
use Ijodkor\ApiResponse\Supporters\ListPaginator;
use Illuminate\Http\JsonResponse;

trait RestResponse {

Expand Down Expand Up @@ -43,7 +42,7 @@ protected function created(array $data = [], string $message = 'Muvaffaqiyatli')
* @param int $status
* @return JsonResponse
*/
protected function fail($errors = [], string $message = 'Muvaffaqiyatsiz', int $status = 400): JsonResponse {
protected function fail(mixed $errors = [], string $message = 'Muvaffaqiyatsiz', int $status = 400): JsonResponse {
return response()->json([
'success' => false,
'errors' => $errors,
Expand Down Expand Up @@ -85,7 +84,7 @@ protected function unAuthorized(string $message = "Kirishga ruxsat berilmagan"):
* @param string $message
* @return JsonResponse
*/
protected function result($data = [], string $message = 'Muvaffaqiyatli'): JsonResponse {
protected function result(mixed $data = [], string $message = 'Muvaffaqiyatli'): JsonResponse {
return response()->json([
'success' => true,
'data' => $data,
Expand All @@ -103,12 +102,12 @@ protected function noContent(): JsonResponse {

/**
* Returned paginated response
* @param LengthAwarePaginator $data
* @param mixed $data
* @param string $key
* @param string|null $message
* @return JsonResponse
*/
protected function paginated(LengthAwarePaginator $data, string $key, ?string $message = 'Muvaffaqiyatli'): JsonResponse {
protected function paginated(mixed $data, string $key, ?string $message = 'Muvaffaqiyatli'): JsonResponse {
return response()->json([
'status' => true,
'data' => new ListPaginator($data, $key),
Expand Down
3 changes: 1 addition & 2 deletions src/Supporters/ListPaginator.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Ijodkor\ApiResponse\Supporters;

use Illuminate\Contracts\Pagination\LengthAwarePaginator as Paginator;
use Illuminate\Pagination\LengthAwarePaginator;

class ListPaginator extends LengthAwarePaginator {
Expand All @@ -12,7 +11,7 @@ class ListPaginator extends LengthAwarePaginator {
*/
private string $key;

public function __construct(Paginator $paginator, string $key = "data") {
public function __construct($paginator, string $key = "data") {
$this->key = $key;

$options = ['path' => $paginator->path()];
Expand Down

0 comments on commit 768e2d2

Please sign in to comment.