2017 © Pedro Peláez
 

library ember-eloquent

Laravel package to translate api responses into ember-data readable formats.

image

nuwave/ember-eloquent

Laravel package to translate api responses into ember-data readable formats.

  • Wednesday, July 22, 2015
  • by chrissm79
  • Repository
  • 2 Watchers
  • 3 Stars
  • 51 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 7 Versions
  • 0 % Grown

The README.md

Ember-Eloquent

Introduction

I have been working quite a bit with Ember recently and I wanted to create Ember Data formatted responses including sideloading. This proeject utilizes Fractal's JsonApiSerializer and tweaks it a bit to create json responses that are consumable by ember-data., (*1)

This is still a work in progress, so please use with caution, (*2)

Installation

Install the composer package, (*3)

composer require nuwave/ember-eloquent

Add the service provider to you app.php file, (*4)

'NuWave\Serializers\SerializerServiceProvider',

Publish the config file, (*5)

php artisan vendor:publish

Create your model transformers (Fractal), (*6)

Fractal Transformer Guide, (*7)

Edit the config file with your application namespace (optional: you can also add a suffix if your naming convension utilizes it), (*8)

// config/ember.php

return [
    /*
    |---------------------------------------------------------------------
    | Transformer Namespace
    |---------------------------------------------------------------------
    |
    | Set the default namespace for your transformer
    |
    */
    'namespace' => 'MyApp\Transformers',

    /*
    |---------------------------------------------------------------------
    | Transformer Suffix
    |---------------------------------------------------------------------
    |
    | Set the suffix for your transformer naming convention.
    |
    | Default value is null
    */
    'suffix' => null
];

Add EmberTrait to your controllers (or your base Controller). This will allow you to utilize the emberResponse method which takes your Model/Collection along with the model name and transforms it into an ember-data formatted response., (*9)

class UserController extends Controller {

  use EmberTrait;

  public function index()
  {
    $users = User::all();

    // or

    $users = User::paginate(20); // meta data will be included in response

    return $this->emberResponse($users, 'User');
  }

  // ...

  public function show($id)
  {
    $user = User::find($id);

    return $this->emberResponse($user, 'User');
  }
}

The Versions

22/07 2015

dev-master

9999999-dev

Laravel package to translate api responses into ember-data readable formats.

  Sources   Download

MIT

The Requires

 

by Christopher Moore

22/07 2015

1.3.2

1.3.2.0

Laravel package to translate api responses into ember-data readable formats.

  Sources   Download

MIT

The Requires

 

by Christopher Moore

22/07 2015

1.3.1

1.3.1.0

Laravel package to translate api responses into ember-data readable formats.

  Sources   Download

MIT

The Requires

 

by Christopher Moore

22/07 2015

1.3

1.3.0.0

Laravel package to translate api responses into ember-data readable formats.

  Sources   Download

MIT

The Requires

 

by Christopher Moore

14/06 2015

1.2.0

1.2.0.0

Laravel package to translate api responses into ember-data readable formats.

  Sources   Download

MIT

The Requires

 

by Christopher Moore

29/04 2015

1.1.0

1.1.0.0

Laravel package to translate api responses into ember-data readable formats.

  Sources   Download

MIT

The Requires

 

by Christopher Moore

02/04 2015

v1.0.0

1.0.0.0

Laravel package to translate api responses into ember-data readable formats.

  Sources   Download

MIT

The Requires

 

by Christopher Moore