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

Task::user()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
eloc 1
nc 1
nop 0
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