Passed
Push — main ( 2daf18...4b2a2f )
by Tan
04:31 queued 02:02
created

Page::slug()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 2
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace CSlant\Blog\Core\Models;
4
5
use AllowDynamicProperties;
6
use CSlant\Blog\Core\Models\Base\BasePage;
7
use Illuminate\Database\Eloquent\Builder;
8
use Illuminate\Database\Eloquent\Relations\HasOne;
9
10
/**
11
 * Class Page
12
 *
13
 * @package CSlant\Blog\Core\Models
14
 *
15
 * @property int $id
16
 * @property string $name
17
 * @property string $description
18
 * @property string $content
19
 * @property string $status
20
 * @property string $template
21
 * @property string $image
22
 * @property int $user_id
23
 *
24
 * @method static Builder|Page newModelQuery()
25
 * @method static Builder|Page newQuery()
26
 * @method static Builder|Page query()
27
 * @method static Builder|Page first()
28
 * @method static Builder|Page find($id)
29
 * @method static Builder|Page with($relations)
30
 * @method static Builder|Page whereId($value)
31
 * @method static Builder|Page whereIn($column, $values)
32
 * @method static Builder|Page where($column, $operator = null, $value = null, $boolean = 'and')
33
 * @method static Page findOrFail($id)
34
 * @method static Page create($data)
35
 *
36
 * @mixin BasePage
37
 */
38
#[AllowDynamicProperties]
39
class Page extends BasePage
40
{
41
    /**
42
     * @return HasOne<Slug>
43
     */
44
    public function slug(): HasOne
45
    {
46
        return $this->hasOne(Slug::class, 'reference_id', 'id')
47
            ->where('reference_type', $this->getBaseModel());
48
    }
49
}
50