mderakhshi/laravel-pocket-data

Custom PHP Pocket Data library for the Laravel 6

dev-master 2020-03-09 21:46 UTC

This package is auto-updated.

Last update: 2024-11-10 08:23:36 UTC


README

pocket data is package server side rendering for fetch multi route

Installation

composer require mderakhshi/laravel-pocket-data --no-cache

Usage:

route : {laravelPath}/pocketData/
method : POST
parameters: json

Structure:

parameters json:
{
    "routes":{
        "${route.key}":{
            "url":"${route.path}",
            "method":"(get|post|put|patch|delete)", 
            "parameters":{"object":"object"}
        }
    }
}

Default method: get

Default parameters: []

Response:
{
    "${route.key}":"${route.content}"
}

Example

parameters json:
{
    "routes":{
        "api.user.update.1":{
            "url":"/api/user/1/",
            "method":"patch",
            "parameters":{
                "name": "masoud",
                "last_name": "derakhshi"
            }
        },
        "api.user.delete.2":{
            "url":"/api/user/2/",
            "method":"delete"
        },
        "api.user.get.3":{
            "url":"/api/user/3/"
        }
    }
}
Response:
{
    "api.user.update.1": {
        "id": "1",
        "name": "masoud",
        "last_name": "derakhshi",
        "updated_at": "2020/01/01 12:00:00"
    },
    "api.user.delete.2": true,
    "api.user.get.3": {
        "id": "3",
        "name": "masoud",
        "last_name": "derakhshi",
        "created_at": "2020/01/01 12:00:00",
        "updated_at": "2020/01/01 12:00:00"
    }
}

License

MIT