diff options
Diffstat (limited to 'src/Models/News.php')
-rw-r--r-- | src/Models/News.php | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/Models/News.php b/src/Models/News.php index 55ab9c1d..febaae3a 100644 --- a/src/Models/News.php +++ b/src/Models/News.php @@ -6,15 +6,19 @@ 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 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) @@ -42,4 +46,13 @@ class News extends BaseModel 'is_meeting', 'user_id', ]; + + /** + * @return HasMany + */ + public function comments(): HasMany + { + return $this->hasMany(NewsComment::class) + ->orderBy('created_at'); + } } |