Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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