Download the PHP package whitecube/laravel-prices without Composer

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

laravel-prices

Manage acquisition, selling & renting prices for products and services in your Laravel Application

Installation

Configuration

You can publish the config file by running this command:

Once your configuration file is created in config/prices.php, you can edit the Price model to a custom Price model by changing:

Quick overview

This package lets you attach prices to anything you want, and keeps a history of the price changes overtime.

To achieve that, the package will migrate a prices table which is used to store every price change that occurs on your priceable items (such as products or services). When you access your item's price, the most recent result in that table will be returned.

This documentation will use a fake Product model as an example, however you can link these prices to anything you want.

Usage

Add the HasPrices trait to your Product model.

This unlocks the whole functionality of this package for that model. Here are the things you can now do:

Setting a price

You can pass additional arguments, such as the type (defaults to selling, more on this later) and the moment the price needs to come into effect.

or if you want to avoid the use statement

It's important to note that this package uses whitecube/php-prices under the hood. This allows you to later do accurate calculations with your prices, without running into problems with floating point number precision.

This means it converts the price into "minor units" (aka cents) before storage in the database. The value you specify when creating a new price can be either in major or minor units. To define a price directly in minor units, use the minor argument instead of amount:

Getting the current selling price

The quickest and easiest way, getting a Whitecube\Price\Price instance so you're ready to do accurate calculations with it.

By default, this will return the latest price that has the selling type, but you can change that by overriding the getDefaultPriceType method on your class. It must return a string that corresponds to the price type you want to use by default for that priceable item class.

Accessing the relationship manually

The above example does a little magic via an accessor method on the trait to make the most common use case easier, but behind the scenes it's a simple query on a relation. You can query this relation yourself when necessary (and with the help of the current() scope, it will only return the currently active price).

Do note that this returns an instance of the Whitecube\LaravelPrices\Models\Price model, not a Whitecube\Price\Price instance. To access that manually, call :

How to handle one-off prices

The main way to use prices with this package is to use it as a chronological history table of all the prices for a specific item. This means you should define the activated_at attribute when creating the price so that the system can accurately make a decision on whether or not it should consider the price when you query it.

However, you may sometimes need to specify a special one-off price for an item, without it getting applied automatically every time. This can be done easily by leaving out or setting the activated_at attribute to null, and storing the price's ID where you need to have a reference to it. When you do so, these prices will never be returned when using time-based scopes (such as current() or effectiveAt()).

Available scopes

current()

Filters the query to only return the current price model.


effectiveAt($date)

Filters the query to only return the price model that was active at the given time (accepts a Carbon instance)


oneOffs()

Filters the query to only return the one-off prices (activated_at === null)


🔥 Sponsorships

If you are reliant on this package in your production applications, consider sponsoring us! It is the best way to help us keep doing what we love to do: making great open source software.

Contributing

Feel free to suggest changes, ask for new features or fix bugs yourself. We're sure there are still a lot of improvements that could be made, and we would be very happy to merge useful pull requests.

Thanks!

Made with ❤️ for open source

At Whitecube we use a lot of open source software as part of our daily work. So when we have an opportunity to give something back, we're super excited!

We hope you will enjoy this small contribution from us and would love to Twitter for more updates!


All versions of laravel-prices with dependencies

PHP Build Version
Package Version
Requires whitecube/php-prices Version ^3.0
illuminate/support Version ^8.0|^9.0|^10.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 whitecube/laravel-prices contains the following files

Loading the files please wait ....