Page::scopeBySlug()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
1
<?php
2
3
namespace Ngtfkx\Laradeck\Pages\Models;
4
5
use Illuminate\Database\Eloquent\Builder;
6
use Illuminate\Database\Eloquent\Model;
7
8
/**
9
 * Ngtfkx\Laradeck\Pages\Models\Page
10
 *
11
 * @property int $id
12
 * @property \Carbon\Carbon $created_at
13
 * @property \Carbon\Carbon $updated_at
14
 * @property string $header Заголовок страницы
15
 * @property string $content Текст страницы
16
 * @property string $slug Слаг страницы
17
 * @method static \Illuminate\Database\Query\Builder|Page bySlug($slug)
18
 */
19
class Page extends Model
20
{
21
    protected $fillable = [
22
        'header', 'content', 'slug',
23
    ];
24
25
    /**
26
     * Выбрать по слагу
27
     *
28
     * @param Builder $query
29
     * @param string $slug
30
     * @return Builder
31
     */
32
    public function scopeBySlug(Builder $query, string $slug): Builder
33
    {
34
        return $query->where('slug', '=', $slug);
35
    }
36
}
37