Download the PHP package jedrzej/withable without Composer

On this page you can find all versions of the php package jedrzej/withable. 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 withable

Withable trait for Laravel's Eloquent models

This package adds possibility to dynamically eager load Eloquent models relations in Laravel 4/5/6 using request parameters.

You could also find those packages useful:

Composer install

Add the following line to composer.json file in your project:

"jedrzej/withable": "0.0.6"

or run the following in the commandline in your project's root folder:

composer require "jedrzej/withable" "0.0.6"

Setting up withable models

In order to make an Eloquent model withable, add the trait to the model and define a list of relations that can be eagerly loaded using request paramaters. You can either define a $withable property or implement a getWithableRelations method if you want to execute some logic to define list loadable relations.

In order to make all relations loadable put an asterisk * in the list:

Loading relations

WithableTrait adds a withRelations() scope to the model - you can pass it a list of relations to load as you would pass to Eloquent's with() method:

or it will use Request::all() as default. In the URL you can pass a list of relations to load or a single relation in the with parameter:

Loading scoped relations

If you have defined local scopes in a related model, you can load this relation with the scope applied. E.g. in order to eagerly load posts with their approved comments:

Additional configuration

If you are using with request parameter for other purpose, you can change the name of the parameter that will be interpreted as a list of relations to load by setting a $withParameterName property in your model, e.g.:

If you need to execute additional logic to define a list of relations to load (e.g. permission checking), you can implement getWithRelationsList() method in your model and make that return list of relations:


All versions of withable with dependencies

PHP Build Version
Package Version
Requires illuminate/database Version *
illuminate/support Version *
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 jedrzej/withable contains the following files

Loading the files please wait ....