Created
March 28, 2014 22:18
-
-
Save thewinterwind/9844168 to your computer and use it in GitHub Desktop.
Laravel 4 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 | |
/** | |
* Helpers for Laravel 4 | |
* Author: Anthony Vipond | |
*/ | |
// Preformat the dump and die function | |
if (!function_exists('d')) { | |
function d($mixed) { | |
print '<pre>'; | |
dd($mixed); | |
} | |
} | |
// Quickly set the application to a logged in state | |
if (!function_exists('li')) { | |
function li($id = 36020) { | |
Auth::loginUsingId($id); | |
} | |
} | |
// Quickly set the application to a non-logged in state | |
if (!function_exists('lo')) { | |
function lo() { | |
Auth::logout(); | |
} | |
} | |
// Dump an iterable variable (very useful on Eloquent collections) | |
if (!function_exists('di')) { | |
function di ($mixed) { | |
print "Iterable has " . count($mixed) . " elements"; | |
print "<pre>"; | |
foreach ($mixed as $item) { | |
print_r($item); | |
print "<hr/>"; | |
} | |
die; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment