承接 langleyfoxall/react-dynamic-data-table-laravel-api 相关项目开发

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

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

langleyfoxall/react-dynamic-data-table-laravel-api

Composer 安装命令:

composer require langleyfoxall/react-dynamic-data-table-laravel-api

包简介

Provides a Laravel API endpoint responder for the `react-dynamic-data-table` component.

README 文档

README

This package provides a Laravel API endpoint responder for the React Dynamic Data Table component.

Installation

composer require langleyfoxall/react-dynamic-data-table-laravel-api

Usage

First, create a new route in your API routes file for the data table response, and point it to a controller.

In this controller method, create a new DataTableResponder passing it the model you wish to return data about, and the provided instance of the Request object. You can optionally specify changes to the query (such as sorting, or filtering) using the query method. If you want to alter the data before it gets returned in some way, such as changing attribute values or appending custom attributes, you can take advantage of collectionManipulator. You can also change number of records shown per page with the setPerPage method.

See the example usage below.

use App\User;
use Illuminate\Http\Request;
use LangleyFoxall\ReactDynamicDataTableLaravelApi\DataTableResponder;

class UsersController extends Controller
{
    public function dataTable(Request $request)
    {
        return (new DataTableResponder(User::class, $request))
            ->query(function($query) {                                   // Optional, default: none
                $query->where('name', 'like', 'B%');
            })
            ->collectionManipulator(function (Collection $collection) {  // Optional, default: none
                $collection->map(function($user) {
                    $user->name = title_case($user->name);
                });
            })
            ->setPerPage(10)                                             // Optional, default: 15
            ->respond();
    }
}

In your frontend code, you can now use the React Dynamic Data Table package's AjaxDynamicDataTable component to display a table of this data. The API route previously defined should be passed to this component as the apiUrl prop.

An example usage is shown below.

import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import AjaxDynamicDataTable from "@langleyfoxall/react-dynamic-data-table/dist/AjaxDynamicDataTable";

export default class Example extends Component {
    render() {
        return (
            <div className="container">
                <AjaxDynamicDataTable apiUrl={'/api/users/data-table'}/>
            </div>
        );
    }
}

if (document.getElementById('example')) {
    ReactDOM.render(<Example />, document.getElementById('example'));
}

Without a model

Sometimes you need to create a table of data for which there is no model (and the data is some kind of aggregation, so a model would not be appropriate).

use App\User;
use Illuminate\Http\Request;
use LangleyFoxall\ReactDynamicDataTableLaravelApi\DataTableResponder;

class UsersController extends Controller
{
    public function dataTable(Request $request)
    {
        return (new DataTableResponder(DB::table('users')->select(['id', 'name']), $request))
            ->query(function($query) {                                   // Optional, default: none
                $query->where('name', 'like', 'B%');
            })
            ->collectionManipulator(function (Collection $collection) {  // Optional, default: none
                $collection->map(function($user) {
                    $user->name = title_case($user->name);
                });
            })
            ->setPerPage(10)                                             // Optional, default: 15
            ->respond();
    }
}

langleyfoxall/react-dynamic-data-table-laravel-api 适用场景与选型建议

langleyfoxall/react-dynamic-data-table-laravel-api 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 16.09k 次下载、GitHub Stars 达 7, 最近一次更新时间为 2018 年 11 月 19 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 langleyfoxall/react-dynamic-data-table-laravel-api 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 langleyfoxall/react-dynamic-data-table-laravel-api 我们能提供哪些服务?
定制开发 / 二次开发

基于 langleyfoxall/react-dynamic-data-table-laravel-api 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 7
  • Watchers: 2
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: LGPL-3.0-only
  • 更新时间: 2018-11-19