![]() ![]() |
Info | ![]() |
![]() |
![]() ![]() |
Reputation | Support forum | Blog | Links |
Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
2020-03-04 (5 months ago) ![]() | Not yet rated by the users | Total: 41 | All time: 9,885 This week: 306![]() |
Version | License | PHP version | Categories | |||
laravel-currency 1.0.0 | Custom (specified... | 5 | PHP 5, E-Commerce, Finances |
// 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 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
<a name="config"></a>
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>
$list = currenciesList();
/
* "USD" => "US Dollar"
* "CAD" => "Canadian Dollar"
* "EUR" => "Euro"
* "AED" => "United Arab Emirates Dirham"
* ...
*/
<a name="cu"></a>
$product->setCurrency(15.59, 'USD');
<a name="get"></a>
// 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>
$product->deleteCurrency('EGP'); // Delete EGP Currency
$product->clearCurrencies(); // Clear all currencies
<a name="relationship"></a>
$product->currencies; // All currencies list of a single model
<a name="scopes"></a>
// 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>
// Get User Model
$product->currency()->user;
![]() |
File | Role | Description | ||
---|---|---|---|---|
![]() |
||||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Lic. | License text | ||
![]() ![]() |
Doc. | Documentation |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.