Download the PHP package testmonitor/eloquent-calculated-columns without Composer
On this page you can find all versions of the php package testmonitor/eloquent-calculated-columns. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download testmonitor/eloquent-calculated-columns
More information about testmonitor/eloquent-calculated-columns
Files in testmonitor/eloquent-calculated-columns
Package eloquent-calculated-columns
Short Description A Laravel package for adding calculated columns to Eloquent models using SQL for more performant queries.
License MIT
Informations about the package eloquent-calculated-columns
Eloquent Calculated Columns
A Laravel package for adding calculated columns when retrieving data from an Eloquent model. This package allows you to define these columns using SQL, resulting in more performant queries compared to accessors.
It is heavily inspired by Spatie's Query Builder and can be used in conjunction with this package.
Table of Contents
- Installation
- Usage
- Examples
- Tests
- Changelog
- Contributing
- Credits
- License
Installation
This package can be installed through Composer:
Next, publish the configuration file:
The configuration file allows you the change the HTTP parameter name, when desired.
Usage
To use calculated columns, you need to:
- Use the trait in your model.
- Define the available calculated in your model.
Add the CalculatedColumns trait to the models where you want to add calculated columns:
Next, use the calculated columns in your queries:
In this example, the total_price column calculates the total price of an order by adding all the order item prices.
The requested columns are automatically derived from the HTTP request. You can
modify the HTTP query parameter in the configuration file. By default,
the name calculate is used.
Examples
Tests
The package contains integration tests. You can run them using PHPUnit.
Changelog
Refer to CHANGELOG for more information.
Contributing
Refer to CONTRIBUTING for contributing details.
Credits
- Thijs Kok
- Stephan Grootveld
- Frank Keulen
- All Contributors
License
The MIT License (MIT). Refer to the License for more information.
All versions of eloquent-calculated-columns with dependencies
illuminate/support Version ^12.0
illuminate/database Version ^12.0
illuminate/config Version ^12.0