Skip to content

Commit

Permalink
Add Model::transform() for simple transformer support.
Browse files Browse the repository at this point in the history
Signed-off-by: crynobone <crynobone@gmail.com>
  • Loading branch information
crynobone committed Jul 17, 2016
1 parent 4a5c64e commit d47e936
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Eloquent.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,16 @@ public function transaction(Closure $callback)
{
return $this->getConnection()->transaction($callback);
}

/**
* Transform each attribute in the model using a callback.
*
* @param callable $callback
*
* @return \Illuminate\Support\Fluent
*/
public function transform(callable $callback)
{
return new Illuminate\Support\Fluent($callback($this));
}
}

0 comments on commit d47e936

Please sign in to comment.