承接 fazzinipierluigi/laraccoon_datasource 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

fazzinipierluigi/laraccoon_datasource

Composer 安装命令:

composer require fazzinipierluigi/laraccoon_datasource

包简介

A Laravel library that processes server-side requests from the Raccoon Tables JavaScript plugin and returns the expected response format

README 文档

README

Laravel library that processes server-side requests from the Raccoon Tables JavaScript plugin and returns the expected response format.

Supports Laravel 9, 10, 11, 12, and 13.

Features

  • Filtering (all Raccoon Tables operators)
  • Sorting (multi-sort)
  • Pagination (start / limit)
  • Global search
  • Row grouping with counts and optional aggregations

Installation

composer require fazzinipierluigi/laraccoon_datasource

Basic usage

use Fazzinipierluigi\LaraccoonDatasource\EloquentSource;

public function index(Request $request)
{
    $users = \App\Models\User::where('is_admin', 0);

    $source = new EloquentSource();
    $source->apply($users, $request);
    return $source->getResponse();
}

Method signature

$source->apply(
    $data_set,       // Eloquent\Builder or Query\Builder
    $request,        // Illuminate\Http\Request
    $field_map,      // optional — maps client field index → DB column(s)
    $search_fields,  // optional — field indexes included in globalSearch
    $aggregations    // optional — ['fieldIndex' => 'sum|avg|min|max|count'] for group agValues
);

Field map

Maps the client-side index to one or more DB columns. Useful when the client field name differs from the DB column, or when one grid column maps to multiple DB columns (ORed together for filters).

$field_map = [
    'fiscal_reference' => ['users.tax_code', 'users.vat'], // OR match on both columns
    'creation_date'    => 'created_at',
];

$source->apply($users, $request, $field_map);

Global search

Pass an array of field indexes to search when the globalSearch / search parameter is present. Each field is resolved through $field_map to its DB column(s) and ORed together.

$source->apply($users, $request, $field_map, ['name', 'email', 'fiscal_reference']);

Custom row transform

return $source->getResponse(function ($row) {
    return [
        'username'         => $row->username,
        'fiscal_reference' => $row->is_company ? $row->vat : $row->tax_code,
        'creation_date'    => $row->created_at->format('d/m/Y'),
    ];
});

Group aggregations

When rowGroups is active the response includes a groups map. Pass $aggregations to have the server compute per-group sums/averages.

$source->apply($employees, $request, $field_map, null, [
    'salary' => 'sum',
    'bonus'  => 'sum',
    'age'    => 'avg',
]);

Response:

{
  "data": [...],
  "total": 284,
  "groups": {
    "Engineering": { "amount": 142, "agValues": { "salary": 9230000, "bonus": 1420000, "age": 34.2 } },
    "Marketing":   { "amount": 87,  "agValues": { "salary": 4350000, "bonus": 522000,  "age": 31.7 } }
  }
}

Supported filter operators

sign Behavior
= Contains (LIKE %value%)
!= Not contains
== Equals exact
!== Not equals
> Greater than
< Less than
a_ Starts with
_a Ends with
regex REGEXP (MySQL/MariaDB)
empty IS NULL or empty string
!empty IS NOT NULL and not empty string
+ Numeric >= 0
- Numeric < 0
in whereIn (value must be an array)
T Boolean true
F Boolean false or NULL

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-06-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固