This file contains hidden or 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('human_file_size')) { | |
/** | |
* Returns a human readable file size | |
* | |
* @param integer $bytes | |
* Bytes contains the size of the bytes to convert | |
* | |
* @param integer $decimals |
This file contains hidden or 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('human_file_size')) { | |
function human_file_size($bytes, $decimals = 2) | |
{ | |
// ... | |
} | |
} |
This file contains hidden or 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
"autoload": { | |
"files": [ | |
"app/Helpers/Helper.php" | |
], | |
"classmap": [ | |
"database/seeds", | |
"database/factories" | |
], | |
"psr-4": { | |
"App\\": "app/" |
This file contains hidden or 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
public function register() | |
{ | |
$file = app_path('Helpers/Helper.php'); | |
if (file_exists($file)) { | |
require_once($file); | |
} | |
} |
This file contains hidden or 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
public function register() | |
{ | |
foreach (glob(app_path() . '/Helpers/*.php') as $file) { | |
require_once($file); | |
} | |
} |
This file contains hidden or 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 | |
Route::get('/', function () { | |
return human_file_size(1024*1024); | |
}); |
This file contains hidden or 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
function tap($value, $callback) | |
{ | |
$callback($value); | |
return $value; | |
} |
This file contains hidden or 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 | |
return tap($photo, function($photo) { | |
$photo->validated = true; | |
$photo->save(); | |
}); |
This file contains hidden or 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
function tap($value, $callback = null) | |
{ | |
if (is_null($callback)) { | |
return new HigherOrderTapProxy($value); | |
} | |
$callback($value); | |
return $value; | |
} |
This file contains hidden or 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 | |
$photo = App\Photo::find(1); | |
return tap($photo)->update([ | |
'validated' => 'true', | |
]) |
OlderNewer