Download the PHP package coburncodes/presenter without Composer
On this page you can find all versions of the php package coburncodes/presenter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download coburncodes/presenter
More information about coburncodes/presenter
Files in coburncodes/presenter
Package presenter
Short Description A presenter package for Laravel 5.5+ based off of the package by Laracasts
License
Informations about the package presenter
Laravel View Presenter
The coburncodes/presenter
package allows you to easily integrate view presenters to keep your models tidy.
This packaged is adopted from Laracasts' view presenter
. This package is compatible with Laravel v5.6+.
This package also provides extra conveniences like:
- Publish a config file to change the path of your view presenters
- Includes an artisan command to generate new view presenters for your models.
Install
You can install the package via composer:
Config file
A config file can be published if you would like to change the default location of where the presenters are stored. By default, the view presenters are stored in the Presenters
directory in the app root. Simply publish the config file by running:
Find the presenter vendor
Usage
Add trait to model:
To implement a view Presenter to a model add the presentable
trait to your model.
Create the presenter using Artisan
An artisan command is included in the package to generate a view presenter for a model. Simply run:
Follow the command prompts. Enter the name of the model that you want to create a presenter for as well as to create an initial method to present.
Create the presenter manually
You can manually create a presenter in your Presenters
directory. The package uses the convention of ModelPresenter
as the class name for each presenter. i.e. UserPresenter
. See the following example:
Implement in your view
Before integrating this package, you might write:
This becomes very messy and you are not DRYing up your code.
Using this package, you add the present()
method plus the method name you used in your presenter.
License
The MIT License (MIT). Please see License File for more information.