Last active
November 1, 2017 16:20
-
-
Save gjreasoner/c89fd60d09623c78104c19a7e6e2e1b9 to your computer and use it in GitHub Desktop.
David refactor
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
// 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') |
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
<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