Skip to content

Instantly share code, notes, and snippets.

@thewinterwind
Created March 28, 2014 22:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save thewinterwind/9844168 to your computer and use it in GitHub Desktop.
Save thewinterwind/9844168 to your computer and use it in GitHub Desktop.
Laravel 4 Helpers
<?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