2017 © Pedro Peláez
 

library laravel-fractalhelper

Compatible with Laravel 5+ and Lumen 5+.

image

eventhomes/laravel-fractalhelper

Compatible with Laravel 5+ and Lumen 5+.

  • Friday, July 29, 2016
  • by roundedvision
  • Repository
  • 3 Watchers
  • 8 Stars
  • 40,298 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 11 % Grown

The README.md

Laravel 5 / Lumen 5 Fractal Api Controller

A simple api controller helper utilizing league fractal. You also get all the functionality provided by https://github.com/eventhomes/laravel-apicontroller, (*1)

Installation

composer require eventhomes/laravel-fractalhelper, (*2)

Basic Usage

By default, this helper will use ArraySerializer(), no setup required. You may, however, need to parse the GET includes., (*3)

...
use EventHomes\Api\FractalHelper;

class MyController extends Controller {

    use FractalHelper;

    public function __construct(Request $request)
    {
        $this->parseIncludes($request->get('includes', ''));
    }
}

Customize Fractal

If you need to change the default ArraySerializer(), you can modify., (*4)

...
use EventHomes\Api\FractalHelper;

class MyController extends Controller {

    use FractalHelper;

    public function __construct(Manager $manager, Request $request)
    {
        $manager->setSerializer(new JsonApiSerializer);
        $this->setFractal($manager)->parseIncludes($request->get('includes', ''));
    }
}

Respond with item

public function show($id)
{
    $user = User::find($id);
    return $this->respondWithItem($user, new UserTransformer);
}

Respond with collection

public function index()
{
    $users = User::all();
    return $this->respondWithCollection($users, new UserTransformer);
}

Respond with collection, paginated

public function index()
{
    $users = User::paginate(10);
    return $this->respondWithCollection($users, new UserTransformer);
}

The Versions

29/07 2016

dev-master

9999999-dev

Compatible with Laravel 5+ and Lumen 5+.

  Sources   Download

MIT

The Requires

 

by Bill Richards

laravel api lumen fractal api controller

29/07 2016

dev-develop

dev-develop

Compatible with Laravel 5+ and Lumen 5+.

  Sources   Download

MIT

The Requires

 

by Bill Richards

laravel api lumen fractal api controller

29/07 2016

v0.1.4

0.1.4.0

Compatible with Laravel 5+ and Lumen 5+.

  Sources   Download

MIT

The Requires

 

by Bill Richards

laravel api lumen fractal api controller

15/01 2016

0.1.3

0.1.3.0

Compatible with Laravel 5+ and Lumen 5+.

  Sources   Download

MIT

The Requires

 

by Bill Richards

laravel api lumen fractal api controller

22/06 2015

0.1.2

0.1.2.0

Compatible with Laravel 5+ and Lumen 5+.

  Sources   Download

MIT

The Requires

 

by Bill Richards

laravel api lumen fractal api controller

22/06 2015

0.1.1

0.1.1.0

Compatible with Laravel 5+ and Lumen 5+.

  Sources   Download

MIT

The Requires

 

by Bill Richards

laravel api lumen fractal api controller

21/06 2015

0.1.0

0.1.0.0

Compatible with Laravel 5+ and Lumen 5+.

  Sources   Download

MIT

The Requires

 

by Bill Richards

laravel api lumen fractal api controller