flatorb/moldssp 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

flatorb/moldssp

最新稳定版本:1.1.6

Composer 安装命令:

composer require flatorb/moldssp

包简介

A package library to use laravel pagination with datatables and mongodb.

README 文档

README

Software License Travis Total Downloads

This package library makes it easier to use Laravel server side pagination functionality with MongoDB and Datatables (datatables.net).

Install

composer require flatorb/moldssp

Usage

DataTables.net plugin

Add the datatables.net javascript library to your application either using CDN.

View

On your blade (view) file establish the table with the following base structure.

<table class="table" id="postsTable">
    <thead>
        <tr>
            <th class="text-center">ID</th>
            <th class="text-center">Title</th>
            <th class="text-center">Author</th>
            <th class="text-center">Date</th>
            <th class="text-center">Status</th>
        </tr>
    </thead>
    <tbody></tbody>
</table>

And within your script tags of the page:

<script type="text/javascript">
    $(document).ready(function () {
        $.ajaxSetup({
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            }
        });

        $('#postsTable').DataTable({
            serverSide: true,
            ajax: {
                url: '/api/posts',
                data: function(d) {
                    d.page = (d.start/d.length) + 1;
                },
                dataFilter: function(data) {
                    var json = jQuery.parseJSON(data);
                    json.recordsTotal = json.total;
                    json.recordsFiltered = json.total;

                    return JSON.stringify(json);
                }
            },
            language: {
                lengthMenu: "Show _MENU_",
            },
            dom: "<'row'" + "<'col-sm-6 d-flex align-items-center justify-conten-start'l>" + "<'col-sm-6 d-flex align-items-center justify-content-end'f>" + ">" + "<'table-responsive'tr>" + "<'row'" + "<'col-sm-12 col-md-5 d-flex align-items-center justify-content-center justify-content-md-start'i>" + "<'col-sm-12 col-md-7 d-flex align-items-center justify-content-center justify-content-md-end'p>" + ">",
            processing: true,
            bStateSave: true,
            fixedHeader: {
                headerOffset: 119
            },
            lengthMenu: [
                [10, 25, 50, 100, 150, -1],
                [10, 25, 50, 100, 150, "All"]
            ],
            pageLength: 25,
            pagingType: "full_numbers",
            order: [[3, "desc"]],
            deferRender: true,
            columns: [
                { "data": "customID" },
                { "data": "title" },
                { "data": {"_":"authorID", "display":"author.name" }},
                { "data": "date" },
                { "data": {"_":"statusID", "display":"status.name" }}
            ]
        });
    });
</script>

Controller

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;

use App\Models\Post;

use Flatorb\Moldssp\Moldssp;

class PostsController extends Controller
{
    public function __construct() {
        // your own code here
    }

    public function index(Request $request)
    {
        return Moldssp::paginator(Post::query(), $request);
    }
}

Issues

If you discover any functionality or compatibility issues (other than security issues), please use the Github bug tracker to report them.

Security

If you discover any security-related issues, please email packages@flatorb.com instead of using the issue tracker.

Testing

Need to implement. Contributions to this section will be highly values.

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

We encourage contribution to this package

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-09-07