2017 © Pedro Peláez
 

library presenter

Simple and straightforward presenter implementation for Eloquent models.

image

tequilarapido/presenter

Simple and straightforward presenter implementation for Eloquent models.

  • Monday, March 5, 2018
  • by nbourguig
  • Repository
  • 2 Watchers
  • 0 Stars
  • 3,549 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 19 % Grown

The README.md

Simple and straightforward presenter implementation for Eloquent models., (*1)

Latest Version on Packagist Software License Build Status StyleCI SensioLabsInsight Quality Score Code Coverage, (*2)

, (*3)

Contents

Installation

You can install the package using composer, (*4)

``` bash $ composer require tequilarapido/presenter, (*5)


## Usage Let's assume we have a User model class ``` php class User extends Model { protected $fillables = ['first_name', 'last_name']; }
  • 1/ Create a presenter class like the following, and add presentation methods to it. For the example, we'll make a method that will return the user full name.

``` php use Tequilarapido\Presenter\Presenter;, (*6)

class UserPresenter extends Presenter {
public function name() { return $this->first_name . ' ' . $this->last_name; } }, (*7)


> We can access model property directly inside the presenter class. We can also access them via the $model property ``` php $this->first_name // or $this->model->first_name // or $this->model->getAttribute('first_name')
  • 2/ you need to reference this class in the model using a public $presenter property and use the Prensentable trait.

``` php use Tequilarapido\Presenter\Presentable;, (*8)

class User extends Model { use Presentable;, (*9)

protected $fillables = ['first_name', 'last_name'];, (*10)

public $presenter = UserPresenter::class; }, (*11)


* 3/ You can than get the presented value like so : ``` php $user = User::find(1); // Retreive as property $user->present()->name // you can alse call the method $user->present()->name()

Changelog

Please see CHANGELOG for more information what has changed recently., (*12)

Testing

bash $ composer test, (*13)

Security

If you discover any security related issues, please email :author_email instead of using the issue tracker., (*14)

Contributing

Please see CONTRIBUTING for details., (*15)

Credits

License

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

The Versions

05/03 2018

dev-master

9999999-dev https://github.com/tequilarapido/presenter

Simple and straightforward presenter implementation for Eloquent models.

  Sources   Download

MIT

The Requires

 

The Development Requires

05/03 2018
28/08 2017

dev-develop

dev-develop https://github.com/tequilarapido/presenter

Simple and straightforward presenter implementation for Eloquent models.

  Sources   Download

MIT

The Requires

 

The Development Requires

28/08 2017
25/01 2017

1.0.0

1.0.0.0 https://github.com/tequilarapido/presenter

Simple and straightforward presenter implementation for Eloquent models.

  Sources   Download

MIT

The Requires

 

The Development Requires

14/10 2016

0.0.1

0.0.1.0 https://github.com/tequilarapido/presenter

Simple and straightforward presenter implementation for Eloquent models.

  Sources   Download

MIT

The Requires

 

The Development Requires