PHPackages                             martijnthomas/presenter - 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. martijnthomas/presenter

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

martijnthomas/presenter
=======================

Decorating Eloquent Models

07PHP

Since Jan 4Pushed 7y ago1 watchersCompare

[ Source](https://github.com/MartijnThomas/Presenter)[ Packagist](https://packagist.org/packages/martijnthomas/presenter)[ RSS](/packages/martijnthomas-presenter/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependenciesVersions (1)Used By (0)

Presenter
=========

[](#presenter)

Decorate Eloquent models.

Installation
------------

[](#installation)

This package can be used in Laravel 5.4 or higher.

You can install the package via composer:

```
composer require martijnthomas/presenter
```

In Laravel 5.5 the service provider will automatically get registered. In older versions of the framework just add the service provider in `config/app.php` file:

```
'providers' => [
    // ...
    MartijnThomas\Presenter\PresenterServiceProvider::class,
];
```

Usage
-----

[](#usage)

First, add the `MartijnThomas\Presenter\Presentable` trait to your `Eloquent` model(s):

```
namespace App;

use Illuminate\Database\Eloquent\Model;
use MartijnThomas\Presenter\Presentable;

class Product extends Model
{
    use Presentable;

    // ...
}
```

Next, you can create a `ModelPresenter`, this class has to extend the `MartijnThomas\Presenter\PresenterAbstract`. Within the created `ModelPresenter` you can add methods representing your presenters.

You can access your original model data through `$this->model`.

```
namespace App\Presenters;

use MartijnThomas\Presenter\PresenterAbstract;

class ProductPresenter extends PresenterAbstract
{
    /**
     * Format the amount
     *
     * @return string
     */
    public function amount()
    {
        return $this->model->amount / 100;
    }
}
```

Then there is one thing left to do, you need to register the presenter within your model. This is simple:

```
namespace App;

use App\Presenters\ProductPresenter;
use Illuminate\Database\Eloquent\Model;
use MartijnThomas\Presenter\Presentable;

class Product extends Model
{
    use Presentable;

    /**
     * Set the Presenter for the Model
     *
     * @var \App\Presenters\ProductPresenter
     */
    protected $presenter = ProductPresenter::class;

    // ...
}
```

Now you can access your decorated properties as follows:

```
$product = Product::find(1);

$product->present()->amount;
```

Enjoy!

Open ends
---------

[](#open-ends)

Packages is not yet fully featured, still needs to do:

- Add generator for the presenters

###  Health Score

19

—

LowBetter than 9% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3868?v=4)[Michael Thomas](/maintainers/MThomas)[@mthomas](https://github.com/mthomas)

### Embed Badge

![Health badge](/badges/martijnthomas-presenter/health.svg)

```
[![Health](https://phpackages.com/badges/martijnthomas-presenter/health.svg)](https://phpackages.com/packages/martijnthomas-presenter)
```

###  Alternatives

[sun-asterisk/laravel-domain-verify

Verify domain ownership for Laravel application

201.1k](/packages/sun-asterisk-laravel-domain-verify)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
