Documentation
What Does This Package Do?
This package basically provides "Currency CRUD" and "A Helper Which is Helps You to Choose Your Currency In FrontSide And Stores As Session" so you dont need to worry about managing your currenciesInstallation
Step 1
composer require azizyus/currencymanager
Step 2
AddCurrencyManager\CurrencyManagerServiceProvider::class, Former\FormerServiceProvider::class,to config/app.php
Step 3 (Migrations)
php artisan vendor:publish --tag=azizyus/currencymanager-publish-migrations
Im already loading migrations with ->loadMigrationsFrom, but if it doenst work just publish them and use it
(that means you can migrate without publishing but in case if you want to override or etc... just do it as i said)
Config File
php artisan vendor:publish --tag=azizyus/currencymanager-publish-config
As i mentioned at first, this package helps you too choose your currency in frontside so you have some config parameters about them, you can change both of middlewares and prefixes or namespacesreturn [ 'usePackageRoutes' => true, 'middleWares' => ['web'], 'prefix' => 'currency', 'frontPrefix' => 'currency_front', 'frontMiddlewares' => ['web'], 'controllerNamespace' => 'CurrencyManager\Controllers', 'frontControllerNamespace' => 'CurrencyManager\Controllers', ];
Routes
I'm using Route::resource routes for crud operations for default and they are;currency.index
currency.edit
currency.update
currency.create
currency.store
currency.delete
and because of these also you need to pass {{method_fields(' ')}} if you want to customize package also there is front routes to change your currency;
route("currency.change",["id"=>"_YOUR_CURRENCY_ID"]);
route("currency.current");
last one shows your current currency as json for more like testing purposes i dont think anyone want to use that
Controllers
You will be have 2 controller in package; CurrencyController, which is gives crud operations and CurrencyFrontController and this one gives you currency changing feature, you can inheritance them and change some specific parts of like a edit page's view file or you can pass a modified repository with some of your specific operationsFAQ
What does CurrencyHelper do?
It manages your selected currency via sessions for you, all you need is; take instance and ->getCurrencyOrDefault(); and if you dont have any error ($currencyHelperInstance->errorThrower->hasError) you can use your currency safelyI want to exchange my currency with another one what to do?
I got CurrencyExchangeCalculator for that, pass your base and target currency Instances to ctor and ->setPrice(); then you can calculate right price by ->baseToTarget();I need to use my own controllers what to do?
Just extend one of my controllers and currencyManager config file should look like this;return [ 'usePackageRoutes' => true, 'middleWares' => ['web'], 'prefix' => 'currency', 'frontPrefix' => 'currency_front', 'frontMiddlewares' => ['web'], 'controllerNamespace' => "App\\Http\\Controllers", 'frontControllerNamespace' => "App\\Http\\Controllers", ];