讨论数量: 0
L07 Laravel 教程 - Laravel TDD 测试实战
/
本节我们来进行些重构。
完成了前两节的内容之后,我们发现我们重复了comments()
、comment()
和getCommentsCountAttribute()
方法,所以本节我们进行些重构,将这些方法抽取到 trait 当中,以便复用。新建 trait 如下:
app/Models/Traits/CommentTrait.php
<?php
namespace App\Models\Traits;
trait CommentTrait
{
public function comment($content
本文章首发在 LearnKu.com 网站上。
粤ICP备18099781号-6
|
粤公网安备 44030502004330号
|
违法和不良信息举报
由 Summer 设计和编码 ❤