InteractionModel   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
dl 0
loc 21
rs 10
c 1
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A toDto() 0 3 1
A user() 0 3 1
A page() 0 3 1
1
<?php
2
3
4
namespace App\Src\UseCases\Infra\Sql\Model;
5
6
7
use App\Src\UseCases\Domain\Context\Dto\InteractionDto;
8
use App\User;
9
use Illuminate\Database\Eloquent\Model;
10
11
class InteractionModel extends Model
12
{
13
    protected $table = 'interactions';
14
15
    protected $fillable = ['follow', 'applause', 'done', 'page_id', 'value'];
16
17
    protected $casts = ['value' => 'array', 'start_done_at' => 'datetime'];
18
19
    public function page()
20
    {
21
        return $this->belongsTo(PageModel::class, 'page_id', 'page_id');
22
    }
23
24
    public function user()
25
    {
26
        return $this->belongsTo(User::class, 'user_id', 'id');
27
    }
28
29
    public function toDto():InteractionDto
30
    {
31
        return new InteractionDto($this->page_id, $this->follow, $this->done, $this->applause, $this->start_done_at);
32
    }
33
}
34