2017 © Pedro Peláez
 

library eloquent-ql

A library that provides content negotiation

image

brunaobh/eloquent-ql

A library that provides content negotiation

  • Wednesday, June 20, 2018
  • by brunaobh
  • Repository
  • 1 Watchers
  • 1 Stars
  • 4 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

brunaobh/eloquent-ql

This library helps to negotiate content related to eloquent models (fields, relations and filters), (*1)

Installation

Install the package using composer:, (*2)

$ composer require brunaobh/eloquent-ql

Publish the package configuration: $ php artisan vendor:publish --provider="brunaobh\Search\Search\SearchServiceProvider", (*3)

That's it., (*4)

Simple usage

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\User;
use Search;

class UserController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index(Request $request)
    {
        $res = Search::handleRequest($request)
            ->negotiate('User')
            ->get();

        return response()->json($res);
    }

Create your filter, (*5)

public function scopeFilterByAddressNotNull($query)
{
   return $query->whereNotNull('address');
}

Now you simply call your route with your filter and the fields you want to return in the request, (*6)

http://localhost:8000/api/users?fields=name,email&filters=filterByAddressNotNull

Using with Laravel

Service Provider (Optional on Laravel 5.5)

Once Composer has installed or updated your packages you need add aliases or register you packages into Laravel. Open up config/app.php and find the aliases key and add:, (*7)

Providers:, (*8)

brunaobh\Search\Search\SearchServiceProvider::class,

Aliases:, (*9)

brunaobh\Search\Search\SearchServiceProvider::class,

'Search' => brunaobh\Search\Facades\Search::class,

Contact

Bruno Coelho brunaobh@gmail.com, (*10)

License

This project is distributed under the MIT License. Check [LICENSE][LICENSE.md] for more information., (*11)

The Versions

20/06 2018

dev-master

9999999-dev

A library that provides content negotiation

  Sources   Download

MIT

The Requires

 

The Development Requires

by Bruno Coelho

20/06 2018

1.0.4

1.0.4.0

A library that provides content negotiation

  Sources   Download

MIT

The Requires

 

The Development Requires

by Bruno Coelho

20/06 2018

1.0.3

1.0.3.0

A library that provides content negotiation

  Sources   Download

MIT

The Requires

 

The Development Requires

by Bruno Coelho

20/06 2018

1.0.2

1.0.2.0

A library that provides content negotiation

  Sources   Download

MIT

The Requires

 

The Development Requires

by Bruno Coelho

20/06 2018

1.0.1

1.0.1.0

A library that provides content negotiation

  Sources   Download

MIT

The Requires

 

The Development Requires

by Bruno Coelho

20/06 2018

1.0.0

1.0.0.0

A library that provides content negotiation

  Sources   Download

MIT

The Development Requires

by Bruno Coelho