Completed
Push — master ( 936afc...005576 )
by Emmanuel
01:16
created

Ticket::reference()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
4
namespace RexlManu\LaravelTickets\Models;
5
6
7
use Illuminate\Database\Eloquent\Model;
8
use RexlManu\LaravelTickets\Traits\HasConfigModel;
9
10
class Ticket extends Model
11
{
12
    use HasConfigModel;
13
14
    protected $fillable = [
15
        'subject',
16
        'priority',
17
        'state',
18
        'category_id'
19
    ];
20
21
    public function getTable()
22
    {
23
        return config('laravel-tickets.database.tickets-table');
24
    }
25
26
    public function messages()
27
    {
28
        return $this->hasMany(TicketMessage::class);
29
    }
30
31
    public function user()
32
    {
33
        return $this->belongsTo(config('laravel-tickets.user'));
34
    }
35
36
    public function category()
37
    {
38
        return $this->belongsTo(TicketCategory::class);
39
    }
40
41
    public function reference()
42
    {
43
        return $this->hasOne(TicketReference::class);
44
    }
45
46
    public function scopeState($query, $state)
47
    {
48
        return $query->where('state', $state);
49
    }
50
51
    public function scopePriority($query, $priority)
52
    {
53
        return $query->where('priority', $priority);
54
    }
55
}
56