Total Complexity | 4 |
Total Lines | 27 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
8 | trait Commentable |
||
9 | { |
||
10 | public function comments() |
||
11 | { |
||
12 | return $this->morphMany(Comment::class, 'commentable'); |
||
|
|||
13 | } |
||
14 | |||
15 | public function comment(string $comment): Comment |
||
16 | { |
||
17 | return $this->newComment(['comment' => $comment]); |
||
18 | } |
||
19 | |||
20 | public function commentAs(Model $user, string $comment): Comment |
||
21 | { |
||
22 | return $this->newComment([ |
||
23 | 'comment' => $comment, |
||
24 | 'user_id' => $user->getKey(), |
||
25 | ]); |
||
26 | } |
||
27 | |||
28 | private function newComment(array $data) |
||
35 | ] |
||
36 | )); |
||
37 | } |
||
38 | } |
||
39 |