Last active
September 15, 2016 21:30
-
-
Save IsraelOrtuno/f472929a7d77e9c97fd21727fa6e3632 to your computer and use it in GitHub Desktop.
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 | |
FormBuilder::macro('openOrModel', function ($post, $put, $model = null) { | |
return ! $model | |
? \Form::open(['route' => $post, 'method' => 'post']) | |
: \Form::model($model, ['route' => $put, 'method' => 'put']); | |
}); | |
// Use it like this: | |
// | |
// For PHP > 7 | |
// {!! Form::openOrModel('user.store', 'user.update', $user ?? null !!} | |
// | |
// For PHP < 7 | |
// {!! Form::openOrModel('user.store', 'user.update', isset($user) ? $user : null !!} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment