PHPackages                             mohamedhabibwork/laravel-model-transformers - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. mohamedhabibwork/laravel-model-transformers

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

mohamedhabibwork/laravel-model-transformers
===========================================

Easy transformation layer for complex model attributes.

04PHP

Since Aug 9Pushed 3y agoCompare

[ Source](https://github.com/mohamedhabibwork/laravel-model-transformer)[ Packagist](https://packagist.org/packages/mohamedhabibwork/laravel-model-transformers)[ RSS](/packages/mohamedhabibwork-laravel-model-transformers/feed)WikiDiscussions master Synced 4d ago

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel 5 Model Transformers
============================

[](#laravel-5-model-transformers)

[![Latest Version on Packagist](https://camo.githubusercontent.com/6a2b6c0a806f075fb471f945841559d5727d6bc771fca9be5fedce3ed97e6104/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7468656d736169642f6c61726176656c2d6d6f64656c2d7472616e73666f726d6572732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/themsaid/laravel-model-transformers)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Total Downloads](https://camo.githubusercontent.com/cbfc11719bb8bb67c0f380e42fd791e344eafd37195f709f5f4555ec6c8ba682/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7468656d736169642f6c61726176656c2d6d6f64656c2d7472616e73666f726d6572732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/themsaid/laravel-model-transformers)

This package helps API developers to easily transform Eloquent models into arrays that are convertible to JSON.

Here's how you use it, let's say you have a model with the following data:

```
{
	"name": "iPhone",
	"type": 1
}
```

Here you use a numerical value to represent the different types, you also have a mutator in the model that maps the numerical value to a string.

Inside the controller we can transform the model to be represented into more API friendly structure.

```
