Skip to content

Instantly share code, notes, and snippets.

@technoknol
Last active September 4, 2017 19:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save technoknol/cd26093c84200fd48cddff512073cffa to your computer and use it in GitHub Desktop.
Save technoknol/cd26093c84200fd48cddff512073cffa to your computer and use it in GitHub Desktop.
Helper in Laravel
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
},
"files":[
"app/helpers.php" /* This line was added to load helper file. Then fire 'composer dump-autoload' command in terminal */
]
},
<?php
// FILE:: put this file here
// app/helpers.php
/*
* Custom helpers functions for project by
* Shyam Makwana
*
* Added By: Shyam Makwana
* Date: 03rd May 2017
*
*/
use Illuminate\Support\Facades\Log;
/*
* Check if string given is valid json or not
*
* @developer Shyam Makwana
* @param $str String given to check for valid json
* @return bool Returns true if json is valid or false
*/
function isJson($str) {
$json = json_decode($str);
return $json && $str != $json;
}
/*
* Logs arguments in log file.
*
* @developer Shyam Makwana
* @return void
*/
function logInfo() {
Log::info(func_get_args());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment