Last active
August 30, 2017 03:28
-
-
Save inxilpro/5f11d9a07309f222d9392cb5d31df50d to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
| // these are the same… | |
| public function create(array $attributes = []) | |
| { | |
| $instance = $this->newModelInstance($attributes); | |
| $instance->save(); | |
| return $instance; | |
| } | |
| // and… | |
| public function create(array $attributes = []) | |
| { | |
| return tap($this->newModelInstance($attributes), function ($instance) { | |
| $instance->save(); // some prefer this, as it's all a single, separate block | |
| }); | |
| } | |
| // and (in 5.4)… | |
| public function create(array $attributes = []) | |
| { | |
| return tap($this->newModelInstance($attributes))->save(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment