I never used this helper before, and I do not see why I should use this. Can someone explain why:

return tap($this->newModelInstance($attributes), function ($instance) { $instance->save(); });

is better than:

return $this->newModelInstance($attributes)->save();

Because if the reason is to return the value, which we definitely will use and definitely will also create variable for it, why not just use it normally?

$model = new Model($attr); $model->save();

In case if the class is not fluent, I do not see why we need to tap into it because in the end we will still store the tapped value into variables anyway.

Building Playtune (https://playtune.app) - Software engineer, writer, designer, and artist.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store