Giter Club home page Giter Club logo

laravel-ssp's Introduction

Laravel SSP-INIT

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.

laravel-ssp's People

Contributors

mrkacmaz avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.