Skip to content

Instantly share code, notes, and snippets.

@gjreasoner
Last active November 1, 2017 16:20
Show Gist options
  • Save gjreasoner/c89fd60d09623c78104c19a7e6e2e1b9 to your computer and use it in GitHub Desktop.
Save gjreasoner/c89fd60d09623c78104c19a7e6e2e1b9 to your computer and use it in GitHub Desktop.
David refactor
// Rough example of a blade macro;
// I think you actually need to use raw php in the return not blade
// check the docs @
function boot(){
Blade::directive('select_condition',function($name){
return '<select name="'.$name.'" id="selectize11">
@foreach(range(0,10) as $n)
<option @if(old(\''.$name.'\') == $n) {{ 'selected' }} @endif>$n</option>
@endforeach
</select>';
})
}
// use
@select_condition('august_condition')
<select name="august_condition" id="selectize11">
@foreach(range(0,10) as $n)
<option @if(old('august_condition') == $n) {{ 'selected' }} @endif>$n</option>
@endforeach
</select>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment