2017 © Pedro Peláez
 

library dconverter

helper tool for converting and formatting Outputs into human readable format

image

sam0hack/dconverter

helper tool for converting and formatting Outputs into human readable format

  • Monday, December 12, 2016
  • by sam0hack
  • Repository
  • 1 Watchers
  • 4 Stars
  • 122,031 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 6 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Total Downloads Monthly Downloads Daily Downloads License, (*1)

laravel-DConverter

A helper tool for converting and formatting Outputs into human readable format., (*2)

Integration in Laravel

Install using Composer

Run composer require sam0hack/dconverter dev-master, (*3)

After you have installed dconverter , open your Laravel config file config/app.php and add the following lines in the $aliases array., (*4)

'DConverter' => sam0hack\dconverter\DC::class,, (*5)

Tools

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, (*6)

Example of SizeFormat()

DC::SizeFormat($attachment->file_size), (*7)

In blade tamplate

{{\sam0hack\dconverter\DC::SizeFormat($attachment->file_size)}}, (*8)

Output examples
  • 99.24 kB
  • 100 Mb
  • 1 GB

Example of Hours()

DC::Hours($date,$date2), (*9)

In blade tamplate

{{\sam0hack\dconverter\DC::Hours($date,$date2)}}, (*10)

Output examples
  • 240
  • 1
  • 60

Example of Percentage()

DC::Percentage($current,$total)

calculate percentage using hours, (*11)

$totalhours = DC::Hours($start_date,$end_date);

$currentHours = DC::Hours($start_date,$now_date);

$percentage = DC::Percentage($currentHours,$totalhours);
Output examples
  • 25
  • 33.0
  • -150

Example of MakeColors()

DC::MakeColors(), (*12)

In blade tamplate

{{\sam0hack\dconverter\DC::MakeColors()}}, (*13)

Output examples
  • "#0951e7"
  • "#071377"
  • "#cdda5d"

Example of DistanceMatrix()

For Setup DistanceMatrix you need to add google API into config/services.php, (*14)

'google'=>[ 'GOOGLE_API_KEY' => env('GOOGLE_MAP_API_KEY') ], OR without using env google'=>[ 'GOOGLE_API_KEY' => 'paste you google map api key here' ],, (*15)

@Note Config key should be GOOGLE_API_KEY, (*16)

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'];
Output examples
  • "2,184 mi"
  • "1 day 8 hours"

DistanceMatrix Modes - Optionals For the calculation of distances, you may specify the transportation mode to use. By default, distances are, (*17)

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)., (*18)

DC::DistanceMatrix($origin, $destination,'walking');

packagist

https://packagist.org/packages/sam0hack/dconverter, (*19)

The Versions

12/12 2016

dev-master

9999999-dev https://github.com/sam0hack/laravel-DConverter

helper tool for converting and formatting Outputs into human readable format

  Sources   Download

GNU General Public License v3.0

The Requires

 

The Development Requires

laravel sam0hack filesizeconverter dconverter