a2design / eloquent-presenter
此包已被放弃,不再维护。作者建议使用 faustbrian/eloquent-presenter 包。
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
安装
使用 Composer 在项目的根目录中要求此包。
$ composer require faustbrian/eloquent-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']; } }
模型
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; } }
安全
如果您在此包中发现安全漏洞,请发送电子邮件至 Brian Faust,邮箱地址为 hello@brianfaust.de。所有安全漏洞都将得到及时处理。
许可
MIT 许可证 (MIT)。请参阅 LICENSE 文件获取更多详细信息。