Skip to content

bluebeetlept/api-toolkit

Repository files navigation

API Toolkit

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

Installation

composer require bluebeetlept/api-toolkit:^1.0@dev

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 in the docs/ directory, powered by Mintlify.

Testing

composer test

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages