Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

[Laravel] Support for ExistsFilter

Đang mở
#7,202 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
52/100
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
laravel, php
Lĩnh vực
api, backend, databases

Hướng nghiên cứu

Bắt đầu bằng cách đọc src/Doctrine/Orm/Filter/ExistsFilter.php, sau đó kiểm tra src/Laravel/Eloquent/Filter để tìm các entry point tương ứng. Thêm phần tương đương trong Laravel để filter[optional_field]=true chọn các giá trị không null và false chọn các giá trị null, đồng thời xác minh hành vi thông qua các request collection JSON:API.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Description
I would like to use the ExistsFilter in Laravel a Laravel project using the JSON:API format. Currently, the ExistsFilter is only implemented under Doctrine ORM, but there is no equivalent under src/Laravel/Eloquent/Filter.

Use Case
Filtering a resource collection based on whether a nullable field is present or not, via a JSON:API-compliant request.

Example

Query:

GET /books?filter[optional_field]=true

Model:

#[
    ApiResource(
        operations: [
            new GetCollection(
                name: 'books',
                parameters: [
                    new QueryParameter(
                        key: 'filter[optional_field]',
                        filter: ExistsFilter::class,
                        property: 'optional_field',
                    ),
                    // ...
                    new QueryParameter(key: 'sort', filter: SortFilter::class),
                ],
            ),
            // ...
        ],
    ),
]
class Book extends Model
{
}

Expected Outcome
This should allow filtering records where optional_field is not null (when true is passed) or is null (when false is passed), similar to how it's done in the Doctrine ORM implementation.

Ngôn ngữ chính
PHP
Star
2.6k
Fork
989
Merge trung bình
1 ngày 23 giờ
Pull request đã merge (30 ngày)
102

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của api-platform/core

Tất cả issue của api-platform/core

Issue tương tự

Thêm issue về PHP

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.