A new way to get data from Laravel ORM (Eloquent)

v0.1.3 2019-10-14 17:30 UTC

This package is auto-updated.

Last update: 2024-10-15 05:00:06 UTC


README

Latest Version on Packagist Build Status Quality Score PHPPackages Rank

There is no need for much implementation, just create an endpoint for your searches and start the server of your application and write your query.

Installation

You can install the package via composer:

composer require marcus-campos/dealer

Publish the package configuration:

php artisan vendor:publish --provider="MarcusCampos\Dealer\DealerServiceProvider"

Usage

Create a Controller. E.g:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Dealer;

class SearchController extends Controller
{
    /**
     * Index
     *
     * @param Request $request
     * @return Json
     */
    public function index(Request $request)
    {
        $query = $request->query('q');
        $result = Dealer::negotiate($query);
        return response()->api($result);
    }
}

Create a route. E.g:

Route::get('search', "SearchController@index");

Make a query. E.g:

GET /api/search?q=user(id,name,email,profile(*))->filters(filterByName('Marcus'))->orderBy(id,desc)->paginate(30)->limit(40)&page=1 HTTP/1.1
Host: localhost:8080
cache-control: no-cache

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email campos.v.marcus@gmail.com instead of using the issue tracker.

Credits

License

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