Skip to content
This repository has been archived by the owner on Oct 18, 2022. It is now read-only.

Talk-Point/tp-rest-develop

Repository files navigation

TP-REST-Framework

Software License Scrutinizer Code Quality Build Status

Laravel package for REST API creation.

Install

Via Composer

$ composer require Talk-Point/TPREST

Usage

In the Controller use

try {
    $models = RESTQuery::create(TestModel::class)->query()->get();
    return response()->json($models);
} catch (QueryException $e) {
    return response()->json(['message' => 'DB Query Exception', 'invalid' => $e->errorInfo[2]], 422);
} catch (Exception $e) {
    return response()->json(['message' => 'DB Query Exception'], 422);
}

Parameter

You can combine the parameter to a big search.

Query Parameter

Easy search in columns

http://localhost:8001/tests?title=Prof

Options:

Filter Parameter with format column=filter;option

http://localhost:8001/tests?title=Prof;!like&sortby=id;desc&number_integer=3;%3C%3E&title=Dr.

Possible Options: equal = < > <= >= <> != like startwith endwith, !like

Matrix Parameter

SortBy

Sort output by a column.

http://localhost:8001/tests?sortby=id;asc
http://localhost:8001/tests?sortby=id;desc

Combine

http://localhost:8001/tests?title=Pro&sortby=id&is_active=false
[
    {
        "id": "49",
        "title": "Prof. Delphine Cremin",
        "is_active": false,
        "number_integer": 7,
        "number_double": 0,
        "created_at": "2016-01-23 15:21:19",
        "updated_at": "2016-01-23 15:21:19"
    },
    {
        "id": "4",
        "title": "Prof. Beryl Daugherty",
        "is_active": false,
        "number_integer": 9,
        "number_double": 174.430750667,
        "created_at": "2016-01-23 15:21:19",
        "updated_at": "2016-01-23 15:21:19"
    }
]

Change log

Please see CHANGELOG for more information what has changed recently.

Testing

$ composer test

Contributing

Please see CONTRIBUTING and CONDUCT for details.

Security

If you discover any security related issues, please email it@talk-point.de instead of using the issue tracker.

Credits

License

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

About

Package for Laravel to create REST API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages