summaryrefslogtreecommitdiff
path: root/src/Models/News.php
blob: febaae3acf8bb0b2849620f346fd7072cbc68043 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php

declare(strict_types=1);

namespace Engelsystem\Models;

use Carbon\Carbon;
use Engelsystem\Models\User\UsesUserModel;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Query\Builder as QueryBuilder;

/**
 * @property int                           $id
 * @property string                        $title
 * @property string                        $text
 * @property bool                          $is_meeting
 * @property Carbon|null                   $created_at
 * @property Carbon|null                   $updated_at
 *
 * @property-read Collection|NewsComment[] $comments
 *
 * @method static QueryBuilder|LogEntry[] whereId($value)
 * @method static QueryBuilder|LogEntry[] whereTitle($value)
 * @method static QueryBuilder|LogEntry[] whereText($value)
 * @method static QueryBuilder|LogEntry[] whereIsMeeting($value)
 * @method static QueryBuilder|LogEntry[] whereCreatedAt($value)
 * @method static QueryBuilder|LogEntry[] whereUpdatedAt($value)
 */
class News extends BaseModel
{
    use UsesUserModel;

    /** @var bool Enable timestamps */
    public $timestamps = true;

    /** @var array */
    protected $casts = [
        'is_meeting' => 'boolean',
    ];

    /** @var array */
    protected $fillable = [
        'title',
        'text',
        'is_meeting',
        'user_id',
    ];

    /**
     * @return HasMany
     */
    public function comments(): HasMany
    {
        return $this->hasMany(NewsComment::class)
            ->orderBy('created_at');
    }
}