直接上图
上面的 $article
等于 php Article::find(1)
ArticleModel 和 UserModel 在model关联关系
ArticleModel
UserPresenter
然后在view里没法这样使用
//这种可以调用,
{{ $article->images() }}
//这种不可以调用,
{{ $article->author->byName() }}
还有个奇怪的现象...
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
在具体的 Presenter 中你需要使用
来获取当前 Presenter 绑定的 Model,因此你这里的代码需要改为:
这样你就可以直接在 blade 模板中直接使用
{{ $article->byName }}