UserTask   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 93
Duplicated Lines 0 %

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A assignedUser() 0 3 1
A user() 0 3 1
A getDeadlineAttribute() 0 3 1
1
<?php
2
3
namespace App\Models;
4
5
use Carbon\Carbon;
6
use Illuminate\Database\Eloquent\Builder;
7
use Illuminate\Database\Eloquent\Relations\BelongsTo;
8
use Illuminate\Database\Eloquent\SoftDeletes;
9
use Illuminate\Database\Query\Builder as QueryBuilder;
10
use IonGhitun\MysqlEncryption\Models\BaseModel;
11
12
/**
13
 * Class UserTask
14
 *
15
 * @property int $id
16
 * @property int $user_id
17
 * @property int $assigned_user_id
18
 * @property string $description
19
 * @property Carbon $deadline
20
 * @property int $status
21
 * @property Carbon|null $created_at
22
 * @property Carbon|null $updated_at
23
 * @property Carbon|null $deleted_at
24
 *
25
 * @property User $user
26
 * @property User $assignedUser
27
 *
28
 * @method static Builder|UserTask newModelQuery()
29
 * @method static Builder|UserTask newQuery()
30
 * @method static Builder|UserTask query()
31
 * @method static Builder|UserTask whereAssignedUserId($value)
32
 * @method static Builder|UserTask whereCreatedAt($value)
33
 * @method static Builder|UserTask whereDeadline($value)
34
 * @method static Builder|UserTask whereDeletedAt($value)
35
 * @method static Builder|UserTask whereDescription($value)
36
 * @method static Builder|UserTask whereId($value)
37
 * @method static Builder|UserTask whereStatus($value)
38
 * @method static Builder|UserTask whereUpdatedAt($value)
39
 * @method static Builder|UserTask whereUserId($value)
40
 * @method static QueryBuilder|UserTask onlyTrashed()
41
 * @method static QueryBuilder|UserTask withTrashed()
42
 * @method static QueryBuilder|UserTask withoutTrashed()
43
 * @method static Builder|BaseModel orWhereEncrypted($column, $value)
44
 * @method static Builder|BaseModel orWhereNotEncrypted($column, $value)
45
 * @method static Builder|BaseModel orderByEncrypted($column, $direction)
46
 * @method static Builder|BaseModel whereEncrypted($column, $value)
47
 * @method static Builder|BaseModel whereNotEncrypted($column, $value)
48
 *
49
 * @package App\Models
50
 */
51
class UserTask extends Model
52
{
53
    use SoftDeletes;
54
55
    /** @var int */
56
    const STATUS_ASSIGNED = 0;
57
58
    /** @var int */
59
    const STATUS_COMPLETED = 1;
60
61
    /** @var bool */
62
    public $timestamps = true;
63
64
    /** @var string */
65
    protected $table = 'user_tasks';
66
67
    /** @var array */
68
    protected $fillable = [
69
        'user_id',
70
        'assigned_user_id',
71
        'description',
72
        'deadline',
73
        'status'
74
    ];
75
76
    /** @var array */
77
    protected $visible = [
78
        'id',
79
        'user_id',
80
        'assigned_user_id',
81
        'description',
82
        'deadline',
83
        'status',
84
        'created_at',
85
        'updated_at',
86
        'user',
87
        'assignedUser'
88
    ];
89
90
    /** @var array */
91
    protected $casts = [
92
        'status' => 'int'
93
    ];
94
95
    /** @var array */
96
    protected $sortable = [
97
        'id',
98
        'description',
99
        'deadline',
100
        'status',
101
        'created_at',
102
        'updated_at',
103
    ];
104
105
    /** @var array */
106
    protected $searchable = [
107
        'description'
108
    ];
109
110
    /** @var array */
111
    protected $filterable = [
112
        'user_id',
113
        'status'
114
    ];
115
116
    /**
117
     * User.
118
     *
119
     * @return BelongsTo
120
     */
121
    public function user()
122
    {
123
        return $this->belongsTo(User::class, 'user_id', 'id');
124
    }
125
126
    /**
127
     * User assigned.
128
     *
129
     * @return BelongsTo
130
     */
131
    public function assignedUser()
132
    {
133
        return $this->belongsTo(User::class, 'assigned_user_id', 'id');
134
    }
135
136
    /**
137
     * @param $value
138
     *
139
     * @return Carbon
140
     */
141
    public function getDeadlineAttribute($value)
142
    {
143
        return Carbon::parse($value);
144
    }
145
}
146