Skip to content

Make responses Responsable and return SuccessResponse from QueryBuilder#2

Merged
brunogaspar merged 1 commit into
mainfrom
feature/responsable-and-query-builder-responses
Apr 25, 2026
Merged

Make responses Responsable and return SuccessResponse from QueryBuilder#2
brunogaspar merged 1 commit into
mainfrom
feature/responsable-and-query-builder-responses

Conversation

@brunogaspar

Copy link
Copy Markdown
Member

SuccessResponse and ErrorResponse now implement Laravel's Responsable interface, so they can be returned directly from controllers without calling ->respond().

QueryBuilder terminal methods (paginate, cursorPaginate, get) now return SuccessResponse instead of raw data, inheriting the resource class from fromResource(). This eliminates the need to repeat the resource class and call ->respond().

Before:
$products = QueryBuilder::for(Product::class, $request)
->fromResource(ProductResource::class)
->paginate();
return $response->success($products, ProductResource::class)->respond();

After:
return QueryBuilder::for(Product::class, $request)
->fromResource(ProductResource::class)
->paginate();

@brunogaspar brunogaspar self-assigned this Apr 25, 2026
@brunogaspar brunogaspar added the changelog:changed Changes in existing functionality label Apr 25, 2026
SuccessResponse and ErrorResponse now implement Laravel's Responsable
interface, so they can be returned directly from controllers without
calling ->respond().

QueryBuilder terminal methods (paginate, cursorPaginate, get) now
return SuccessResponse instead of raw data, inheriting the resource
class from fromResource(). This eliminates the need to repeat the
resource class and call ->respond().

Before:
  $products = QueryBuilder::for(Product::class, $request)
      ->fromResource(ProductResource::class)
      ->paginate();
  return $response->success($products, ProductResource::class)->respond();

After:
  return QueryBuilder::for(Product::class, $request)
      ->fromResource(ProductResource::class)
      ->paginate();
@brunogaspar brunogaspar force-pushed the feature/responsable-and-query-builder-responses branch from e66f58a to 9e33a8a Compare April 25, 2026 16:00
@brunogaspar brunogaspar merged commit 4d1218d into main Apr 25, 2026
4 checks passed
@brunogaspar brunogaspar deleted the feature/responsable-and-query-builder-responses branch April 25, 2026 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog:changed Changes in existing functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant