summaryrefslogtreecommitdiff
path: root/src/Models
diff options
context:
space:
mode:
Diffstat (limited to 'src/Models')
-rw-r--r--src/Models/News/News.php30
-rw-r--r--src/Models/User/User.php10
2 files changed, 40 insertions, 0 deletions
diff --git a/src/Models/News/News.php b/src/Models/News/News.php
new file mode 100644
index 00000000..ae67752b
--- /dev/null
+++ b/src/Models/News/News.php
@@ -0,0 +1,30 @@
+<?php
+declare(strict_types=1);
+
+namespace Engelsystem\Models\News;
+
+use Engelsystem\Models\User\UsesUserModel;
+use Illuminate\Database\Eloquent\Model;
+
+/**
+ * This class represents a news item.
+ */
+class News extends Model
+{
+ use UsesUserModel;
+
+ protected $casts = [
+ 'is_meeting' => 'boolean',
+ ];
+
+ protected $attributes = [
+ 'is_meeting' => false,
+ ];
+
+ protected $fillable = [
+ 'title',
+ 'text',
+ 'is_meeting',
+ 'user_id',
+ ];
+}
diff --git a/src/Models/User/User.php b/src/Models/User/User.php
index af213c4e..cca96dbe 100644
--- a/src/Models/User/User.php
+++ b/src/Models/User/User.php
@@ -4,6 +4,8 @@ namespace Engelsystem\Models\User;
use Carbon\Carbon;
use Engelsystem\Models\BaseModel;
+use Engelsystem\Models\News\News;
+use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Query\Builder as QueryBuilder;
@@ -95,4 +97,12 @@ class User extends BaseModel
->hasOne(State::class)
->withDefault();
}
+
+ /**
+ * @return HasMany
+ */
+ public function news(): HasMany
+ {
+ return $this->hasMany(News::class);
+ }
}