Passed
Push — master ( c57047...e9f946 )
by Mihail
06:06
created

FeedbackPost::getAnswers()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
1
<?php
2
3
namespace Apps\ActiveRecord;
4
5
use Ffcms\Core\Arch\ActiveModel;
6
7
/**
8
 * Class FeedbackPost. Active model for feedback requests posts.
9
 * @package Apps\ActiveRecord
10
 * @property int $id
11
 * @property string $name
12
 * @property string $email
13
 * @property string $message
14
 * @property bool $readed
15
 * @property bool $closed
16
 * @property string $hash
17
 * @property int $user_id
18
 * @property string $ip
19
 * @property string $created_at
20
 * @property string $updated_at
21
 * @property FeedbackAnswer[] $answers
22
 * @property User|null $user
23
 */
24
class FeedbackPost extends ActiveModel
25
{
26
    protected $casts = [
27
        'id' => 'integer',
28
        'name' => 'string',
29
        'email' => 'string',
30
        'message' => 'string',
31
        'readed' => 'boolean',
32
        'closed' => 'boolean',
33
        'hash' => 'string',
34
        'user_id' => 'integer',
35
        'ip' => 'string'
36
    ];
37
38
    /**
39
     * Get feedback answers relation object
40
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
41
     */
42
    public function answers()
43
    {
44
        return $this->hasMany(FeedbackAnswer::class, 'feedback_id');
45
    }
46
47
    /**
48
     * Get user object relation
49
     * @return \Illuminate\Database\Eloquent\Relations\HasOne
50
     */
51
    public function user()
52
    {
53
        return $this->hasOne(User::class, 'id', 'user_id');
54
    }
55
}
56