Last active
August 29, 2015 14:23
-
-
Save vluzrmos/ad29ff6c68b0f8d3d76d to your computer and use it in GitHub Desktop.
Laravel 5.1 Helpers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (!function_exists('faker')) { | |
/** | |
* Generate or get a faker localized instance | |
* @param locale $l | |
* @example | |
* <code> | |
* faker()->name; //will use app locale | |
* faker('pt_BR')->name;//change locale to pt-br | |
* faker()->email; //now the locale is back to default (app.locale or en_US) | |
* </code> | |
* @return \Faker\Generator | |
*/ | |
function faker($l = null) | |
{ | |
static $faker, $locale; | |
if (!$faker or (!$l and $l != $locale)) { | |
$faker = \Faker\Factory::create($l ?: config('app.locale')); | |
$locale = $l; | |
} | |
return $faker; | |
} | |
} | |
if (!function_exists('rksort')) { | |
/** | |
* Sort an associative array by key recursively | |
* | |
* @param array &$array | |
* @return bool | |
*/ | |
function rksort(&$array) | |
{ | |
foreach ($array as &$value) { | |
if (is_array($value)) { | |
rksort($value); | |
} | |
} | |
return ksort($array); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment