Passed
Pull Request — main (#69)
by
unknown
03:08
created

PostView::post()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
cc 1
eloc 1
c 2
b 1
f 0
nc 1
nop 0
dl 0
loc 4
rs 10
1
<?php
2
3
namespace CSlant\Blog\Api\Models;
4
5
use CSlant\Blog\Core\Models\Post;
6
use Illuminate\Database\Eloquent\Model;
7
use Illuminate\Database\Eloquent\Relations\BelongsTo;
8
use Carbon\Carbon;
9
10
/**
11
 * @property int $id
12
 * @property int $post_id
13
 * @property string $ip_address
14
 * @property Carbon $time_check
15
 * @property Carbon|null $created_at
16
 * @property Carbon|null $updated_at
17
 *
18
 * @method static \Illuminate\Database\Eloquent\Builder<\CSlant\Blog\Api\Models\PostView> query()
19
 */
20
class PostView extends Model
21
{
22
    protected $table = 'post_views';
23
24
    protected $fillable = [
25
        'post_id',
26
        'ip_address',
27
        'time_check',
28
    ];
29
30
    protected $casts = [
31
        'time_check' => 'datetime',
32
    ];
33
34
    /**
35
     * Get the post associated with this view.
36
     *
37
     * @return BelongsTo<\CSlant\Blog\Core\Models\Post, \CSlant\Blog\Api\Models\PostView>
38
     * @phpstan-ignore generics.notSubtype
39
     */
40
    public function post(): BelongsTo
41
    {
42
        // @phpstan-ignore-next-line
43
        return $this->belongsTo(Post::class, 'post_id');
44
    }
45
}
46