a2design / eloquent-presenter
This package is abandoned and no longer maintained.
The author suggests using the faustbrian/eloquent-presenter package instead.
Model Presenters for Laravel
2.1.0
2016-11-21 09:54 UTC
Requires
- php: ^5.5 || ^7.0
- illuminate/database: 5.1.* || 5.2.* || 5.3.*
- nesbot/carbon: >=1.21.0
Requires (Dev)
- graham-campbell/testbench: ^3.1
- mockery/mockery: ^0.9.4
- phpunit/phpunit: ^5.0
- scrutinizer/ocular: ~1.1
- squizlabs/php_codesniffer: ~2.3
This package is not auto-updated.
Last update: 2022-02-01 13:03:07 UTC
README
Installation
Require this package, with Composer, in the root directory of your project.
$ composer require faustbrian/eloquent-presenter
Usage
Presenter
use BrianFaust\Presenter\BasePresenter; class CommentPresenter extends BasePresenter { public function getRoutePrefix() { return 'users.posts.comments'; } public function getRouteParameters() { // The ID of the model will be automatically attached to this array at the end // [ // $model->post->user->id, // $model->post->id, // $model->id // "id" is what is specified in $this->getRouteKeyName() // ]; return ['post.user.id', 'post.id']; } }
Model
use BrianFaust\Presenter\HasViewPresenterTrait; use Illuminate\Database\Eloquent\Model; class Comment extends Model { use HasViewPresenterTrait; /** * Get the view presenter for the model. * * @return string */ protected function getPresenter() { return UserPresenter::class; } }
Security
If you discover a security vulnerability within this package, please send an e-mail to Brian Faust at hello@brianfaust.de. All security vulnerabilities will be promptly addressed.
License
The The MIT License (MIT). Please check the LICENSE file for more details.