承接 mrkacmaz/laravel-ssp 相关项目开发

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

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

mrkacmaz/laravel-ssp

最新稳定版本:v0.1-beta

Composer 安装命令:

composer require mrkacmaz/laravel-ssp

包简介

Process server-side processing (SSP) for an Eloquent model, supporting dynamic filtering, sorting, and pagination.

README 文档

README

SSP-INIT is a Laravel package designed to facilitate server-side processing (SSP) for Eloquent models, supporting dynamic filtering, sorting, and pagination. This package simplifies the development of data-intensive applications by abstracting complex server-side operations.

Features

  • Dynamic Filtering: Apply filters based on request parameters.
  • Sorting: Sort data by any model attribute.
  • Pagination: Efficiently paginate the data based on the client's request.
  • Eager Loading: Supports eager loading of relationships to optimize query performance.
  • Response Encoding: Optionally encode the response data.

Requirements

  • PHP ^8.2
  • Laravel ^8.0

Installation

To install the SSP-INIT package, run the following command in the root of your Laravel project:

composer require mrkacmaz/laravel-ssp

Usage

Here is a basic example of how to use the SSP trait in a Laravel controller:

Controller

<?php

namespace App\Http\Controllers;

use Mrkacmaz\LaravelSsp\Traits\SSP;
use App\Models\User;
use Illuminate\Http\Request;

class UserController extends Controller
{
    use SSP;

    public function index(Request $request)
    {
        if ($request->expectsJson()){
            $data = self::processSSP($request, User::class);
            return response()->json($data);
        }
        return view('welcome');
    }
}

Blade File

<x-app-layout>
    <table class="table table-hover">
        <thead>
        <tr>
            <th scope="col">#</th>
            <th scope="col">Full Name</th>
            <th scope="col">Email</th>
        </tr>
        </thead>
        <tbody></tbody>
    </table>
</x-app-layout>

JS File

$(function (){
    $('.table').DataTable({
        serverSide: true,
        processing: true,
        ajax: {
            url: window.location,
            type: 'GET',
            dataSrc: function (data) {
                return JSON.parse(atob(data.data));
            }
        },
        columns: [
            {data: 'id'},
            {data: 'name'},
            {data: 'email'},
        ],
    });
});

In this example, the UserController utilizes the SSP trait to process data for the User model according to the parameters specified in the request.

Configuration

No additional configuration is required to start using SSP-INIT, as it uses Laravel's default configurations.

Support

If you are having issues, please let us know by submitting an issue on GitHub.

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-04-22