PHPackages                             aqjw/resource-typeable - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. aqjw/resource-typeable

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

aqjw/resource-typeable
======================

Extends the capabilities of the Laravel resource to separate it into types.

1.0.0(4y ago)013MITPHPPHP ^7.3|^8.0

Since Jun 26Pushed 4y ago1 watchersCompare

[ Source](https://github.com/aqjw/resource-typeable)[ Packagist](https://packagist.org/packages/aqjw/resource-typeable)[ RSS](/packages/aqjw-resource-typeable/feed)WikiDiscussions master Synced today

READMEChangelog (1)DependenciesVersions (2)Used By (0)

Resource Typeable support
=========================

[](#resource-typeable-support)

This package extends the Laravel resource to separate it into types.

Installation
------------

[](#installation)

Require this package with composer:

```
composer require aqjw/resource-typeable
```

Usage
-----

[](#usage)

To turn your resource into typeable, just use `ResourceTypeable` trait.

```
use Aqjw\ResourceTypeable\ResourceTypeable;
...
class ProductResource extends JsonResource
{
    use ResourceTypeable;
...
```

Now your resource has typeable capabilities.

Example
-------

[](#example)

```
use Aqjw\ResourceTypeable\ResourceTypeable;
...
class ProductResource extends JsonResource
{
    use ResourceTypeable;

    /**
     * Tiny product resource
     *
     * @return array
     */
    public function tiny($request): array
    {
        return [
            'id' => $this->id,
            'title' => $this->title,
            'slug' => $this->slug,
            'price' => $this->price,
        ];
    }

    /**
     * Full product resource
     *
     * @return array
     */
    public function full($request): array
    {
        return array_merge(
            $this->tiny($request),
            [
                'brand' => $this->brand,
                'model' => $this->model,
                'material' => $this->material,
                'size' => $this->size,
                'tags' => $this->tags,
                'color' => $this->color,
                'print' => $this->print,
            ],
        );
    }
}
```

In the controller, you can call the resource as before.

```
...
class ProductController extends Controller
{
    ...
    public function index()
    {
        $products = Product::paginate(9);

        return new ProductCollection($products); // will return tiny resource type
        // or
        return ProductCollection::make($products); // will return tiny resource type
        // or
        return ProductResource::collectionType('full', $products); // will return full resource type
    }
    ...
```

One more example:

```
...
class ProductController extends Controller
{
    ...
    public function show(Product $product)
    {
        return ProductResource::makeType('full', $product);
    }
    ...
```

Configuration
-------------

[](#configuration)

By default the resource type is `tiny`, but you can change it with `$resource_type` variable declaration:

```
use Aqjw\ResourceTypeable\ResourceTypeable;
...
class ProductResource extends JsonResource
{
    use ResourceTypeable;

    /**
     * Resource type
     *
     * @var string
     */
    protected static $resource_type = 'full';
    ...
```

Tips
----

[](#tips)

Resource types are unlimited, you can create any names for them, not just `tiny` and `full`. But keep in mind that they should not override the parent's methods.

License
-------

[](#license)

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

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1467d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3bbc50eee573168342cf8eaa53bcc09048939b7dc4bb79187133c919ce6e1e8b?d=identicon)[aqjw](/maintainers/aqjw)

---

Top Contributors

[![aqjw](https://avatars.githubusercontent.com/u/13101908?v=4)](https://github.com/aqjw "aqjw (1 commits)")

---

Tags

laravelresource

### Embed Badge

![Health badge](/badges/aqjw-resource-typeable/health.svg)

```
[![Health](https://phpackages.com/badges/aqjw-resource-typeable/health.svg)](https://phpackages.com/packages/aqjw-resource-typeable)
```

###  Alternatives

[jasonlewis/resource-watcher

Simple PHP resource watcher library.

226146.4k14](/packages/jasonlewis-resource-watcher)[cloudstudio/resource-generator

Resource Generator for Laravel Nova

107139.6k1](/packages/cloudstudio-resource-generator)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
