Download the PHP package faliure/laravel-resourceable without Composer

On this page you can find all versions of the php package faliure/laravel-resourceable. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-resourceable

faliure/laravel-resourceable

Laravel Resourceable allows you to set a clear relationship between an Eloquent Model and its associated Resource(s): a Model owns its Resources.

As of Laravel 9.5, this is still not obvious. There is indeed a default path to store the main Model's Resource, but you still need to do things like new UserResource($user). That is, you're just creating an instance of a certain resource, and passing the model as an argument. You can even pass some other type of Model, or even something that's not an Eloquent Model (within reason) and everything will work.

With this package, we make the relation explicit and change the code to reflect that a JsonResource of a Model belongs to that Model, not the other way around.


Usage

Use the HasResources trait and implement the Resourceable interface in your Models.

Get a single Model's associated Resource:

Get all of the model's resources:

Get a custom Collection of resources of a given Model:

As you can see, this syntactic sugar puts the Model in the spotlight, and the resource as one of its many associated entities.


Customization

By default, Resourceable assumes your main Model JsonResource follows the standard:

If that's not the case, you may define a property resourceClass in your Resourceable Modem, like so:

Moreover, you can fetch different kinds of Resources for a model, by passing an optinal $resourceClass parameter to any of the methods defined in the interface. Namely:

It's just as simple as that!

How does the resourcesBuilder work?

The resourcesBuilder is a Custom Eloquent Builder that allows you to write Eloquent chains as you normally would, but it modifies the end result to return the associated Resources instead of a Model or a collection of them.

Check faliure/laravel-custom-builder for more information and other usages.


All versions of laravel-resourceable with dependencies

PHP Build Version
Package Version
Requires faliure/laravel-custom-builder Version ^1.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package faliure/laravel-resourceable contains the following files

Loading the files please wait ....