Created
November 21, 2014 17:07
-
-
Save gaulatti/58fc42978b61881dd730 to your computer and use it in GitHub Desktop.
Laravel Base Controller w/Hacks
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 | |
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