Cooldown   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 33
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A scopeExpired() 0 3 1
A model() 0 3 1
1
<?php
2
3
namespace Kurozora\Cooldown\Models;
4
5
use Illuminate\Database\Eloquent\Model;
6
7
class Cooldown extends Model
8
{
9
    protected $table = 'kurozora_cooldowns';
10
    protected $guarded = [];
11
12
    /**
13
     * The attributes that should be mutated to dates.
14
     *
15
     * @var array
16
     */
17
    protected $dates = [
18
        'expires_at',
19
    ];
20
21
    /**
22
     * Returns the model associated with the cooldown.
23
     *
24
     * @return \Illuminate\Database\Eloquent\Relations\MorphTo
25
     */
26
    public function model()
27
    {
28
        return $this->morphTo();
29
    }
30
31
    /**
32
     * Scope a query to only include expired cooldowns.
33
     *
34
     * @param  \Illuminate\Database\Eloquent\Builder  $query
35
     * @return \Illuminate\Database\Eloquent\Builder
36
     */
37
    public function scopeExpired($query)
38
    {
39
        return $query->where('expires_at', '<', now());
40
    }
41
}