Skip to content

bluebeetlept/api-toolkit

Repository files navigation

API Toolkit

Tests Code Analysis License

JSON:API compliant toolkit for building REST APIs with Laravel.

Installation

composer require bluebeetle/api-toolkit

Quick Start

Define a resource:

final class ProductResource extends Resource
{
    protected string $model = Product::class;

    public function attributes(Product $product): array
    {
        return [
            'name' => $product->name,
            'code' => $product->code,
        ];
    }
}

Use it in a controller:

final class ListController
{
    public function __invoke(Request $request)
    {
        return QueryBuilder::for(Product::class, $request)
            ->fromResource(ProductResource::class)
            ->paginate();
    }
}

Documentation

Full documentation is available at bluebeetle.pt/open-source/docs/api-toolkit.

Testing

composer test

Credits

License

Licensed under the MIT license.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages