Passed
Push — main ( bdcf2a...2daf18 )
by Tan
05:16 queued 02:46
created

Post::slug()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
c 0
b 0
f 0
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 Carbon\Carbon;
7
use CSlant\Blog\Core\Models\Base\BasePost;
8
use Illuminate\Database\Eloquent\Builder;
9
use Illuminate\Database\Eloquent\Relations\HasOne;
10
11
/**
12
 * Class Post
13
 *
14
 * @package CSlant\Blog\Core\Models
15
 *
16
 * @property int $id
17
 * @property string $name
18
 * @property string $description
19
 * @property string $content
20
 * @property string $status
21
 * @property int $author_id
22
 * @property string $author_type
23
 * @property int $is_featured
24
 * @property int $view
25
 * @property string $format_type
26
 * @property Carbon $created_at
27
 * @property Carbon $updated_at
28
 * @property Slug $slug
29
 * @property string $url
30
 * @property array $tags
31
 * @property array $categories
32
 * @property string $image
33
 * @property string $author
34
 *
35
 * @method static Builder|Post newModelQuery()
36
 * @method static Builder|Post newQuery()
37
 * @method static Builder|Post query()
38
 * @method static Builder|Post first()
39
 * @method static Builder|Post find($id)
40
 * @method static Builder|Post with($relations)
41
 * @method static Builder|Post whereId($value)
42
 * @method static Builder|Post whereIn($column, $values)
43
 * @method static Builder|Post where($column, $operator = null, $value = null, $boolean = 'and')
44
 * @method static Post findOrFail($id)
45
 * @method static Post create($data)
46
 *
47
 * @mixin BasePost
48
 */
49
#[AllowDynamicProperties]
50
class Post extends BasePost
51
{
52
    public function slug(): HasOne
53
    {
54
        return $this->hasOne(Slug::class, 'reference_id', 'id')
55
            ->where('reference_type', $this->getBaseModel());
56
    }
57
}
58