onuraycicek / currency
This is my package currency
0.0.13
2024-04-19 01:28 UTC
Requires
- php: ^8.1
- spatie/laravel-package-tools: ^1.12.0
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^7.8
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^8.8
- pestphp/pest: ^2.20
- pestphp/pest-plugin-arch: ^2.0
- pestphp/pest-plugin-laravel: ^2.0
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- spatie/laravel-ray: ^1.26
README
Installation
You can install the package via composer:
composer require onuraycicek/currency
php artisan vendor:publish --tag="currency-migrations" php artisan vendor:publish --tag="currency-config" php artisan vendor:publish --tag="currency-seeder" php artisan migrate php artisan db:seed --class=CurrencySeeder
You must be add this libs: Bootstrap 5, Jquery, Select2.
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous"> <link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" /> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js" integrity="sha512-v2CJ7UaYy4JwqLDIrZUI/4hqeoQieOmAZNXBeQyjo21dadnwR+8ZaIJVT8EE2iyI61OV8e6M8PP2/4hpQINQ/g==" crossorigin="anonymous" referrerpolicy="no-referrer"></script> <script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
Finally you must be add the end (footer) of the layout file: (it's required when you want to use "select-active" attribute)
@stack("footer")
Usage
<x-currency-table select-active></x-currency-table>
Attributes:
select-active: It adds a selectbox above the table so you can check your currencies activity values.
$fromId = 53; $toId = 155; $amount = 100; echo \Onuraycicek\Currency\Currency::convertWithId($fromId, $toId, $amount); $fromCurrencyCode = 'TRY'; $toCurrencyCode = 'USD'; $amount = 100; echo \Onuraycicek\Currency\Currency::convert($fromCurrencyCode, $toCurrencyCode, $amount); var_dump(\Onuraycicek\Currency\Currency::getActiveCurrencies()); $currencyCode = 'TRY'; var_dump(\Onuraycicek\Currency\Currency::getCurrency('TRY')); $currencyId = 1; var_dump(\Onuraycicek\Currency\Currency::getCurrencyById($currencyId)); var_dump(\Onuraycicek\Currency\Models\Currency::all());
Config
return [ 'theme' => 'bootstrap5', 'currencies' => ['TRY', 'USD', 'EUR'], // if it is null, currencies with status 1 will be shown. -> ('currencies' => null) ]; theme: bootstrap5, bootstrap4 (not supported yet) currencies: https://www.html-code-generator.com/php/array/currency-names
Testing
composer test
Credits
License
The MIT License (MIT). Please see License File for more information.