Passed
Pull Request — main (#69)
by
unknown
05:31 queued 02:38
created

PostView::post()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
cc 1
eloc 3
c 2
b 1
f 0
nc 1
nop 0
dl 0
loc 9
rs 10
1
<?php
2
3
namespace CSlant\Blog\Api\Models;
4
5
use Carbon\Carbon;
6
use CSlant\Blog\Core\Models\Post;
7
use Illuminate\Database\Eloquent\Model;
8
use Illuminate\Database\Eloquent\Relations\BelongsTo;
9
10
/**
11
 * @property int $id
12
 * @property int $post_id
13
 * @property string $ip_address
14
 * @property null|string $user_agent
15
 * @property Carbon $time_check
16
 * @property null|Carbon $created_at
17
 * @property null|Carbon $updated_at
18
 * @property-read null|Post $post
19
 */
20
class PostView extends Model
21
{
22
    /**
23
     * The attributes that are mass assignable.
24
     *
25
     * @var list<string>
0 ignored issues
show
Bug introduced by
The type CSlant\Blog\Api\Models\list was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
26
     */
27
    protected $fillable = [
28
        'post_id',
29
        'ip_address',
30
        'user_agent',
31
        'time_check',
32
    ];
33
34
    /**
35
     * The attributes that should be cast.
36
     *
37
     * @var array<string, string>
38
     */
39
    protected $casts = [
40
        'time_check' => 'datetime',
41
    ];
42
43
    /**
44
     * Get the post associated with this view.
45
     *
46
     * @phpstan-return \Illuminate\Database\Eloquent\Relations\BelongsTo<\Illuminate\Database\Eloquent\Model, \CSlant\Blog\Api\Models\PostView>
47
     */
48
    public function post(): BelongsTo
49
    {
50
        /** @phpstan-var class-string<\Illuminate\Database\Eloquent\Model> $postClass */
51
        $postClass = Post::class;
52
53
        /** @phpstan-var \Illuminate\Database\Eloquent\Relations\BelongsTo<\Illuminate\Database\Eloquent\Model, \CSlant\Blog\Api\Models\PostView> $relation */
54
        $relation = $this->belongsTo($postClass, 'post_id');
55
56
        return $relation;
57
    }
58
}
59