olymbytes/laravel-presenters

This package is not installable via Composer 1.x, please make sure you upgrade to Composer 2+. Read more about our Composer 1.x deprecation policy.

Add presenters and presentable behaviour to your Laravel app

dev-master 2017-10-16 07:43 UTC

This package is not auto-updated.

Last update: 2021-06-02 14:13:05 UTC


README

The olymbytes/laravel-presenters package allows you to easily add view presenters to your models.

In order to get started, just add the Presentable trait:

class Order extends Model
{
    use Presentable;
}

Here's a little demo of how you can use it after adding the trait:

$order = Order::find(1);
$order->present()->title;

Documentation

Until further documentation is provided, please have a look at the tests.

Installation

You can install the package via composer:

$ composer require olymbytes/laravel-presenters

The package will automatically register itself.

You can publish the config with:

$ php artisan vendor:publish --provider="Olymbytes\Presenters\PresentersServiceProvider" --tag="config"

Note: It is important to the the namespace inside the config file, if you want to have your presenters in a different namespace than App\Presenters.

This is the contents of the published config file:

return [
    'namespace' => 'App\\Presenters',
];

Testing

$ composer test

Security

If you discover any security issues, please email mpj@foreno.dk instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.