2017 © Pedro Peláez
 

library laravel-companion

Laravel support library for JSON-API developers.

image

sarala-io/laravel-companion

Laravel support library for JSON-API developers.

  • Tuesday, April 3, 2018
  • by milroy.me
  • Repository
  • 3 Watchers
  • 3 Stars
  • 587 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 67 % Grown

The README.md

Important: This package is not actively maintained. For bug fixes and new features, please fork. or take a look at sarala-io/sarala, (*1)

Sarala Laravel Companion

Laravel support package to easily develop REST API following JSON API specification., (*2)

Latest Version on Packagist ![Software License][ico-license] Build Status ![Coverage Status][ico-scrutinizer] Quality Score ![Total Downloads][ico-downloads] StyleCI, (*3)

Install

Via Composer, (*4)

``` bash $ composer require sarala-io/laravel-companion, (*5)


## Usage Eloquent model implementation ```php namespace App; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Builder; use Sarala\Filterable; class Post extends Model { use Filterable; ... }

Dedicated query filter implementation ``` php namespace App\Filters;, (*6)

use Sarala\FilterAbstract;, (*7)

class PostsFilter extends FilterAbstract { protected $lookup = [ 'my' => 'composedByMe' ];, (*8)

public function composedByMe()
{
    return $this->builder->composedBy(auth()->user());
}

...

}, (*9)

Controller implementation
```php
namespace App\Http\Controllers;

use App\Post;
use App\Filters\PostsFilter;
use App\Http\Transformers\PostTransformer;
use Sarala\JsonApiResponse;
use Illuminate\Http\Request;

class PostController extends Controller
{
    public function index(Request $request, PostsFilter $filters)
    {
        $data = Post::filter($filters)->paginateOrGet($request);

        return new JsonApiResponse($data, new PostTransformer(), 'posts');
    }

    public function show(Post $post, PostsFilter $filter)
    {
        $data = Post::filter($filter)->find($post->id);

        return new JsonApiResponse($data, new PostTransformer(), 'posts');
    }

    ...
}

Change log

Please see CHANGELOG for more information on what has changed recently., (*10)

Testing

bash $ composer test, (*11)

Contributing

Please see CONTRIBUTING and CODE_OF_CONDUCT for details., (*12)

Security

If you discover any security related issues, please email milroy.me@gmail.com instead of using the issue tracker., (*13)

Credits

License

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

The Versions

03/04 2018
03/04 2018

dev-analysis-86OWvn

dev-analysis-86OWvn https://github.com/sarala-io/laravel-companion

Laravel support library for JSON-API developers.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel eloquent restful json api