Completed
Push — master ( ba0c42...6dd141 )
by Emmanuel
01:17
created

Ticket::messages()   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
    ];
19
20
    public function getTable()
21
    {
22
        return config('laravel-tickets.database.tickets-table');
23
    }
24
25
    public function messages()
26
    {
27
        return $this->hasMany(TicketMessage::class);
28
    }
29
30
    public function user()
31
    {
32
        return $this->belongsTo(config('laravel-tickets.user'));
33
    }
34
35
    public function category()
36
    {
37
        return $this->belongsTo(TicketCategory::class);
38
    }
39
40
    public function scopeState($query, $state)
41
    {
42
        return $query->where('state', $state);
43
    }
44
45
    public function scopePriority($query, $priority)
46
    {
47
        return $query->where('priority', $priority);
48
    }
49
}
50