Package Data | |
---|---|
Maintainer Username: | sam0hack |
Maintainer Contact: | sam.nyx@live.com (sam0hack) |
Package Create Date: | 2016-11-03 |
Package Last Update: | 2019-07-10 |
Home Page: | |
Language: | PHP |
License: | GNU General Public License v3.0 |
Last Refreshed: | 2024-11-17 03:00:19 |
Package Statistics | |
---|---|
Total Downloads: | 122,088 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 8 |
Total Watchers: | 3 |
Total Forks: | 6 |
Total Open Issues: | 1 |
A helper tool for converting and formatting Outputs into human readable format.
Run composer require sam0hack/dconverter dev-master
After you have installed dconverter , open your Laravel config file config/app.php and add the following lines in the $aliases array.
'DConverter' => sam0hack\dconverter\DC::class,
SizeFormat --- SizeFormat convert's the laravel getSize() Or bytes data into kb, mb and gb Hours --- Calculate Hours betweens Two dates Percentage --- Calculate Percentage MakeColors --- Simply generate hex color DistanceMatrix --- Calculate Time and distance between two locations using google distance API
DC::SizeFormat($attachment->file_size)
{{\sam0hack\dconverter\DC::SizeFormat($attachment->file_size)}}
DC::Hours($date,$date2)
{{\sam0hack\dconverter\DC::Hours($date,$date2)}}
#####Output examples
DC::Percentage($current,$total)
calculate percentage using hours
$totalhours = DC::Hours($start_date,$end_date);
$currentHours = DC::Hours($start_date,$now_date);
$percentage = DC::Percentage($currentHours,$totalhours);
DC::MakeColors()
{{\sam0hack\dconverter\DC::MakeColors()}}
For Setup DistanceMatrix you need to add google API into config/services.php
'google'=>[ 'GOOGLE_API_KEY' => env('GOOGLE_MAP_API_KEY') ], OR without using env google'=>[ 'GOOGLE_API_KEY' => 'paste you google map api key here' ],
@Note Config key should be GOOGLE_API_KEY
DC::DistanceMatrix('New York Ave, El Paso, TX 79902, USA','86 W Houston St, New York, NY 10012, USA')
$distance = $dist['distance'];
$time = $dist['time'];
DistanceMatrix Modes - Optionals For the calculation of distances, you may specify the transportation mode to use. By default, distances are
calculated for driving mode. The following travel modes are supported: driving (default) indicates distance calculation using the road network. walking requests distance calculation for walking via pedestrian paths & sidewalks (where available). bicycling requests distance calculation for bicycling via bicycle paths & preferred streets (where available).
DC::DistanceMatrix($origin, $destination,'walking');
https://packagist.org/packages/sam0hack/dconverter