Issues (64)

app/Models/Sound.php (1 issue)

1
<?php
2
3
namespace App\Models;
4
5
use Illuminate\Database\Eloquent\Model;
6
7
class Sound extends Model
8
{
9
    /**
10
     * The database table used by the model.
11
     *
12
     * @var string
13
     */
14
    protected $table = 'sounds';
15
16
    /**
17
     * The attributes that are not mass assignable.
18
     *
19
     * @var array
20
     */
21
    protected $guarded = [
22
        'id',
23
    ];
24
25
    /**
26
     * Fillable fields for a Profile.
27
     *
28
     * @var array
29
     */
30
    protected $fillable = [
31
        'enabled',
32
        'title',
33
        'file',
34
        'sort_order',
35
    ];
36
37
    /**
38
     * Typecasting is awesome.
39
     *
40
     * @var array
41
     */
42
    protected $casts = [
43
        'enabled'       => 'boolean',
44
        'title'         => 'string',
45
        'file'          => 'string',
46
        'sort_order'    => 'integer',
47
    ];
48
49
    /**
50
     * Define the date field.
51
     *
52
     * @var array
53
     */
54
    protected $dates = [
55
        'created_at',
56
        'updated_at',
57
    ];
58
59
    /**
60
     * Scope enabled sounds.
61
     *
62
     * @param \Illuminate\Database\Eloquent\Builder $query
63
     *
64
     * @return \Illuminate\Database\Eloquent\Builder
65
     */
66
    public function scopeEnabledSounds($query)
67
    {
68
        return $query->where('enabled', 1);
69
    }
70
71
    /**
72
     * Scope sorted sounds.
73
     *
74
     * @param \Illuminate\Database\Eloquent\Builder $query
75
     *
76
     * @return \Illuminate\Database\Eloquent\Builder
77
     */
78
    public function scopeSortedSounds($query, $order = 'asc')
79
    {
80
        return $query->orderBy('sort_order', $order);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $query->orderBy('sort_order', $order) also could return the type Illuminate\Database\Query\Builder which is incompatible with the documented return type Illuminate\Database\Eloquent\Builder.
Loading history...
81
    }
82
}
83