直接上图
上面的 $article 等于 php Article::find(1)
ArticleModel 和 UserModel 在model关联关系
ArticleModel
UserPresenter
然后在view里没法这样使用
<code class="php">//这种可以调用,
{{ $article->images() }}</code><code class="php">//这种不可以调用,
{{ $article->author->byName() }}</code>还有个奇怪的现象...
直接上图
上面的 $article 等于 php Article::find(1)
ArticleModel 和 UserModel 在model关联关系
ArticleModel
UserPresenter
然后在view里没法这样使用
<code class="php">//这种可以调用,
{{ $article->images() }}</code><code class="php">//这种不可以调用,
{{ $article->author->byName() }}</code>还有个奇怪的现象...
在具体的 Presenter 中你需要使用
<code> $this->getWrappedObject() </code>
来获取当前 Presenter 绑定的 Model,因此你这里的代码需要改为:
<code>public function byName()
{
$this->getWrappedObject()->author()->nickName;
}</code>这样你就可以直接在 blade 模板中直接使用{{ $article->byName }}
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号