Cooldown::model()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

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