Created
July 15, 2019 12:17
-
-
Save osbre/79f47e545b6dfb4f70dd566313422b18 to your computer and use it in GitHub Desktop.
[LARAVEL HELPERS] My collection of laravel 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 | |
/** | |
* Get old input value, and explode it by comma | |
* @param $key | |
* @return false|string | |
*/ | |
function oldList($key) | |
{ | |
return json_encode( | |
array_filter( | |
explode( | |
",", | |
old($key) | |
) | |
) | |
); | |
} | |
/** | |
* Check is request param exits and have value | |
* @param string $name | |
* @param null $value | |
* @return bool | |
*/ | |
function hasParam(string $name, $value = null) | |
{ | |
if (!request()->has($name)){ | |
return false; | |
} | |
if ($value !== null){ | |
return request()->get($name) === $value; | |
} | |
return true; | |
} | |
/** | |
* @param string $text | |
* @return string | |
*/ | |
function parsedown(string $text) | |
{ | |
$parser = app('parsedown'); | |
return $parser->text($text); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment