承接 sukohi/datatable-resource 相关项目开发

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

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

sukohi/datatable-resource

Composer 安装命令:

composer require sukohi/datatable-resource

包简介

A Laravel package that provides data for Datatable which is jQuery plugin with pagination.

README 文档

README

A Laravel package that provides resource data for Datatable which is jQuery plugin with pagination.

This package is for Datatable and maintained under Laravel 6.x.

Installation

composer require sukohi/datatable-resource:1.*

Usage

Basic usage

// in Route

Route::get('item_resource', function(){

    $query = \App\Item::query();
    
    // Of course you can add any methods here like `where()`, `orderBy()` and even `with()`.
    
    return new DatatableResource($query);

});

Now you can get JSON data that Datatable needs.

with additional values

return new DatatableResource($query, [
    'key_1' => 'value_1',
    'key_2' => 'value_2',
    'key_3' => 'value_3',
]);

Trait

This package contains DatatableResourceTrait that provides kind of useful methods.

In order to use them, set DatatableResourceTrait into your Model as follows.

use Sukohi\DatatableResource\Traits\DatatableResourceTrait;

class class Item extends Model
{
    use DatatableResourceTrait;

hasDatatableSearch()

Check if current access has search parameters.

if($this->hasDatatableSearch()) {

    // Do something...

}

getDatatableSearchKeywords()

You can get search keywords that Datatable submitted.

$keywords = $this->getDatatableSearchKeywords();

foreach($keywords as $keyword) {

    // Do someting...

}

hasDatatableSort()

Check if current access has sort parameters.

if($this->hasDatatableSort()) {

    // Do something...

}

getDatatableSort()

You can get sort parameters that Datatable submitted.

$order_by = $this->getDatatableSort();

// Usage
$column = $order_by->column;
$direction = $order_by->direction;

License

This package is licensed under the MIT License.

Copyright 2020 Sukohi Kuhoh

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-05-12

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固