Skip to content

Instantly share code, notes, and snippets.

@gaulatti
Created November 21, 2014 17:07
Show Gist options
  • Save gaulatti/58fc42978b61881dd730 to your computer and use it in GitHub Desktop.
Save gaulatti/58fc42978b61881dd730 to your computer and use it in GitHub Desktop.
Laravel Base Controller w/Hacks
<?php
class BaseController extends Controller {
/**
* Setup the layout used by the controller.
*
* @return void
*/
protected function setupLayout()
{
if ( ! is_null($this->layout))
{
$this->layout = View::make($this->layout);
}
Form::macro('fileUpload', function($name, $placeholder = null)
{
return '<span class="file"><label for="' . $name . '">' . (($placeholder)?$placeholder:'Browse...') . '</label><input type="file" class="fileUpload" name="' . $name . '"></span>';
});
Form::macro('styledCheckbox', function($name, $placeholder = null)
{
$html = '<span class="styledCheckbox">'
.'<input type="checkbox" class="fileUpload" name="' . $name . '">'
.'<div></div>'
.'<label for="' . $name . '">' . (($placeholder)?$placeholder:'') . '</label>'
.'</span>';
return $html;
});
Form::macro('fontPrice', function($name) {
$html = '<input class="font-price" placeholder="Insert Price..." name="' . $name . '" type="text">';
return $html;
});
Blade::extend(function($value) {
return preg_replace('/\@define(.+)/', '<?php ${1}; ?>', $value);
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment