PHPackages                             bfg/resource - 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. [Framework](/categories/framework)
4. /
5. bfg/resource

ActiveBfg-app[Framework](/categories/framework)

bfg/resource
============

A small addition to the resources to the Laravel

v3.2.8(6mo ago)165.5k—8.7%11MITPHPPHP &gt;=8.0.0

Since Sep 19Pushed 6mo ago2 watchersCompare

[ Source](https://github.com/bfg-s/resource)[ Packagist](https://packagist.org/packages/bfg/resource)[ RSS](/packages/bfg-resource/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (41)Used By (1)

Extension resource
==================

[](#extension-resource)

Install
-------

[](#install)

```
composer require bfg/resource
```

Description
-----------

[](#description)

A small addition to the resources to the `Laravel`, which is a dumb modifiable due to the overridency of the main team of the `Laravel` to the new Stub in which another resource inheritance is included which, in turn, everything is also inherited from `Illuminate\Http\Resources\Json\JsonResource` so that the reasons of the `Laravel` will understand it as a full-fledged resource.

About the concept.
------------------

[](#about-the-concept)

The concept of expansion is to reduce resources and make them more flexible and versatile. The flexibility lies in the fact that each field is to have an independent additional possibility of obtaining data on paths and the use of the `Laravel Eloquent Casts` and `Laravel Eloquent Mutators`. Also knows how to determine the relationship of models and connect the fields when they are loaded. Rule for pagination.

Possibilities
-------------

[](#possibilities)

The possibilities of this package in aggregate with the `bfg/route` pack allow me to organize a not big but very powerful pattern for api that can compete with convenience with the `GraphQL`.

Where can I use it?
-------------------

[](#where-can-i-use-it)

This package is intended only in order to make an add-in over the framework Laravel. With the full use of the package, it is rapidly back and efficiently implement a resistant API resource for models and not only.

Create new resource
-------------------

[](#create-new-resource)

In order to create a resource, it is enough to use the standard Command:

```
php artisan make:resource user
```

I added some properties there:

```
-m, --model[=MODEL]   Create with the model
-r, --route           Create with route
-c, --collection      Create a resource collection
```

After execution, the `app/Http/Resources/UserResource.php` file will be created with the following contents:

```
