summaryrefslogtreecommitdiff
path: root/src/Models/News.php
diff options
context:
space:
mode:
authorMichael Weimann <mail@michael-weimann.eu>2019-11-12 21:49:43 +0100
committerMichael Weimann <mail@michael-weimann.eu>2019-11-12 21:58:40 +0100
commit26b8d2b92190de6ce4bbf6ccbb3f1a4f1a735d1d (patch)
treea4fc97930e7f1c309cc90e53c29700b12ede58d7 /src/Models/News.php
parentc0bf0b56f1359025d4bd95f7480c45aed6ad9c9a (diff)
Introduce the NewsComments model
Diffstat (limited to 'src/Models/News.php')
-rw-r--r--src/Models/News.php26
1 files changed, 19 insertions, 7 deletions
diff --git a/src/Models/News.php b/src/Models/News.php
index 55ab9c1d..6f0e96fa 100644
--- a/src/Models/News.php
+++ b/src/Models/News.php
@@ -1,20 +1,23 @@
<?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 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 +45,13 @@ class News extends BaseModel
'is_meeting',
'user_id',
];
+
+ /**
+ * @return HasMany
+ */
+ public function comments(): HasMany
+ {
+ return $this->hasMany(NewsComment::class)
+ ->orderBy('created_at');
+ }
}