Passed
Push — master ( 37fbce...eb9638 )
by Mihail
09:07
created

Apps/ActiveRecord/CommentPost.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace Apps\ActiveRecord;
4
5
use Ffcms\Core\Arch\ActiveModel;
6
7
/**
8
 * Class CommentPost. Active record model for comment posts.
9
 * @package Apps\ActiveRecord
10
 * @property int $id
11
 * @property string $pathway
12
 * @property int $user_id
13
 * @property string|null $guest_name
14
 * @property string $message
15
 * @property string $lang
16
 * @property string $created_at
17
 * @property string $updated_at
18
 */
19 View Code Duplication
class CommentPost extends ActiveModel
0 ignored issues
show
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
20
{
21
    /**
22
     * Get user identity
23
     * @return User|null
24
     */
25
    public function getUser()
26
    {
27
        return User::identity($this->user_id);
28
    }
29
30
    /**
31
     * Get comment post->answers relation
32
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
33
     */
34
    public function getAnswer()
35
    {
36
        return $this->hasMany('Apps\\ActiveRecord\\CommentAnswer', 'comment_id');
37
    }
38
39
    /**
40
     * Get answers count for post comment id
41
     * @return int
42
     */
43
    public function getAnswerCount()
44
    {
45
        return CommentAnswer::where('comment_id', '=', $this->id)->count();
46
    }
47
48
}