-
Notifications
You must be signed in to change notification settings - Fork 0
Lex Usage
Add Lex to your controller / model / page / etc....
Use Lex;
Then use any of the available methods or scopes.
✋ NOTE : the method examples on this page assume a base value of 1.
convert($from, $to = '1', $quantity = '1')
Converts from one currency type to another currency type. The default $to parameter is the row with id 1 in the currency table. The default $quantity parameter is for 1 of the $from currency. If a specified currency is not-convertible or retired or devalued, this method will return a string informing you of that fact instead of a value.
Lex::convert('Dollar') // returns 100
The following will convert 4 Dollars to quarters.
Lex::convert('Dollar', 'Quarter', 4); // returns 16
The following will not convert as "Black Crystals" are not available for conversion.
Lex::convert('Black Crystals') // returns "Black Crystals are not convertible."
The following will not convert as "Red Crystals" have been retired and devalued.
Lex::convert('Red Crystals') // returns "Black Crystals is devalued and worthless. (Originally : 25000000)'
convertToBase($from, $quantity = '1')
Lex will attempt to convert to base using slug "base" (see Create documentation) or lowest available valued currency. This will return the same values as "convert" (above).
Lex::convertToBase('Dollar', 2); // returns 200
convertToCommon($from, $quantity = '1')
Lex will attempt to convert to your common currency using slug "common" or highest valued currency that is both available and convertible.
Lex::convertToCommon('Nickels', 40); // returns 2 Dollars
value($cur)
Returns the base value of the currency type provided. Will also return the value of non-convertible currencies but will return the same strings as above for retired or devalued currencies.
Lex::value('Gold') // returns 111000.
getBaseCurrency()
Returns the base currency object.
getCommonCurrency()
Returns the common currency object.
convertible( boolean );
Returns eloquent object. Defaults to "true".
The following example returns all currencies that are convertible.
Lex::convertible()->get(); // or Lex::convertible(true)->get();
The following example returns all currencies that are not convertible.
Lex::convertible(false)->get();
tradeable( boolean );
Returns eloquent object. Defaults to "true".
The following example returns all currencies that are tradeable.
Lex::tradeable()->get(); // or Lex::tradeable(true)->get();
The following example returns all currencies that are not tradeable.
Lex::tradeable(false)->get();
rewardable( boolean );
Returns eloquent object. Defaults to "true".
The following example returns all currencies that are rewardable.
Lex::rewardable()->get(); // or Lex::rewardable(true)->get();
The following example returns all currencies that are not rewardable.
Lex::rewardable(false)->get();
sellable( boolean );
Returns eloquent object. Defaults to "true".
The following example returns all currencies that are sellable.
Lex::sellable()->get(); // or Lex::sellable(true)->get();
The following example returns all currencies that are not sellable.
Lex::sellable(false)->get();
discoverable( boolean );
Returns eloquent object. Defaults to "true".
The following example returns all currencies that are discoverable.
Lex::discoverable()->get(); // or Lex::discoverable(true)->get();
The following example returns all currencies that are not discoverable.
Lex::discoverable(false)->get();
available( int );
Returns eloquent object. Defaults to "true".
The following example returns all currencies that are not available (0, 1, or 2).
Lex::available(0)->get();
type( string );
Returns eloquent object. Defaults to "true".
The following example returns all currencies that are of type 'common'.
Lex::type('common')->get();