Multiple Currency Laravel Service: Manage product prices in multiple currencies

Recommend this page to a friend!
  Info   View files Documentation   View files View files (15)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2020-03-04 (4 months ago) RSS 2.0 feedNot yet rated by the usersTotal: 41 All time: 9,871 This week: 306Up
Version License PHP version Categories
laravel-currency 1.0.0Custom (specified...5PHP 5, E-Commerce, Finances
Description Author

This package can manage product prices in multiple currencies.

It comes with a Laravel service provider and a trait to allow making product prices appear customized for each user in a given currency.

The list of supported currencies for the product prices is determined from the values set in a configuration script.

Innovation Award
PHP Programming Innovation award nominee
March 2020
Number 11
International e-commerce sites that show products with prices in the currency that the current buyer uses in his country tend to sell more because it is easier for the buyer to understand the product price than if the price was in a foreign currency.

This package provides a solution to retrieve product prices expressed in the currency of the current user country.

Manuel Lemos
Picture of Moamen Eltouny
Name: Moamen Eltouny <contact>
Classes: 10 packages by
Country: Egypt Egypt
Age: 27
All time rank: 365442 in Egypt Egypt
Week rank: 28 Up1 in Egypt Egypt Up
Innovation award
Innovation award
Nominee: 5x

Details

[RaggiTech] Laravel >= 6.0 - Currency.

Latest Stable Version Total Downloads License

Laravel Currency provides a quick and easy methods with 150+ Currency.

Example:

// Create/Update Currency
$product->setCurrency(15.59, 'USD');

// Retrieve Currency's Value
echo $product->currency('USD'); 			// 15.59
echo $product->currencyWithSymbol('USD'); 	// $15.59
echo $product->currencyWithCode('USD'); 	// 15.59 USD

Install

Install the latest version using Composer:

$ composer require raggitech/laravel-currency

then publish the migration & config files

$ php artisan vendor:publish --tag=laravel-currency
$ php artisan migrate

Usage

<a name="config"></a>

Configurations

Default Currency & Only List

use RaggiTech\Laravel\Currency\Currency;

Currency::setDefault('USD'); // Setting USD as a default currency.
Currency::setOnly(['USD', 'EGP']); // Allow using only USD, EGP.

<a name="list"></a>

Currencies List

$list = currenciesList();
/
*	"USD" => "US Dollar"
* 	"CAD" => "Canadian Dollar"
* 	"EUR" => "Euro"
* 	"AED" => "United Arab Emirates Dirham"
* 	...
*/

<a name="cu"></a>

Create / Update Currency's Value

$product->setCurrency(15.59, 'USD');

<a name="get"></a>

Retrieve Currency's Value

// 15.59 if USD is the default currency
// NULL if there's no value for the default currency.
echo $product->currency();

echo $product->currency('USD'); 			// 15.59		|| NULL
echo $product->currencyWithSymbol('USD'); 	// $15.59		|| NULL
echo $product->currencyWithCode('USD'); 	// 15.59 USD	|| NULL

<a name="dc"></a>

Delete a single currency || Clear all model's currencies

$product->deleteCurrency('EGP'); 	// Delete EGP Currency
$product->clearCurrencies();		// Clear all currencies

<a name="relationship"></a>

Relationship

$product->currencies; 	// All currencies list of a single model

<a name="scopes"></a>

Scopes

// Get every element has no currency.
$p1 = Product::withoutCurrencies()->get();

// Get every element has EGP currency.
$p2 = Product::withCurrency('EGP')->get();

// Get every element has [EGP or USD or all] currency.
$p3 = Product::withAnyCurrency(['EGP', 'USD'])->get();

<a name="u"></a>

Creator

// Get User Model
$product->currency()->user;

License

MIT license

  Files folder image Files  
File Role Description
Files folder imagesrc (4 files, 5 directories)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  src  
File Role Description
Files folder imageconfig (1 file)
Files folder imagedata (1 file)
Files folder imagedatabase (1 directory)
Files folder imageExceptions (2 files)
Files folder imageTraits (3 files)
  Plain text file Currency.php Class Class source
  Plain text file CurrencyServiceProvider.php Class Class source
  Plain text file hasCurrency.php Class Class source
  Accessible without login Plain text file Helpers.php Aux. Auxiliary script

  Files folder image Files  /  src  /  config  
File Role Description
  Accessible without login Plain text file currency.php Conf. Configuration script

  Files folder image Files  /  src  /  data  
File Role Description
  Accessible without login Plain text file currencies.php Conf. Configuration script

  Files folder image Files  /  src  /  database  
File Role Description
Files folder imagemigrations (1 file)

  Files folder image Files  /  src  /  database  /  migrations  
File Role Description
  Plain text file currencies.stub Class Class source

  Files folder image Files  /  src  /  Exceptions  
File Role Description
  Plain text file NotAllowedCurrencyException.php Class Class source
  Plain text file UnknownCurrencyException.php Class Class source

  Files folder image Files  /  src  /  Traits  
File Role Description
  Plain text file Info.php Class Class source
  Plain text file Relationships.php Class Class source
  Plain text file Scopes.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:41
This week:0
All time:9,871
This week:306Up

For more information send a message to info at phpclasses dot org.