Skip to content

Instantly share code, notes, and snippets.

@osbre
Created July 15, 2019 12:17
Show Gist options
  • Save osbre/79f47e545b6dfb4f70dd566313422b18 to your computer and use it in GitHub Desktop.
Save osbre/79f47e545b6dfb4f70dd566313422b18 to your computer and use it in GitHub Desktop.
[LARAVEL HELPERS] My collection of laravel helpers
<?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