Completed
Push — master ( a6fcc7...8b8ff2 )
by Quim González
04:41
created

Task   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A toArray() 0 11 2
A user() 0 3 1
1
<?php
2
3
namespace App;
4
5
use Illuminate\Database\Eloquent\Model;
6
7
class Task extends Model
8
{
9
    protected $fillable = ['name', 'user_id', 'description', 'completed'];
10
11
    public function user()
12
    {
13
        return $this->belongsTo(User::class);
14
    }
15
16
17
    public function toArray()
18
    {
19
        return [
20
            'id'          => $this->id,
21
            'name'        => $this->name,
22
            'description' => $this->description,
23
            'user_id'     => $this->user_id,
24
//            'completed' => (Boolean) $this->completed, aquesta linia fa el mateix que la següent.
25
            'completed'  => $this->completed ? true : false,
26
            'created_at' => $this->created_at->toDateTimeString(),
27
            'updated_at' => $this->updated_at->toDateTimeString(),
28
        ];
29
    }
30
}
31