summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIgor Scheller <igor.scheller@igorshp.de>2019-11-03 00:25:35 +0100
committerIgor Scheller <igor.scheller@igorshp.de>2019-11-03 00:25:35 +0100
commita514ba3adc76cb37ab6211640967aa164d56a9c5 (patch)
tree348019851df95aacd96d920f9d56682bbfa855e3 /src
parent4c81fee548a25acfa543b8fc95d9505204f9974b (diff)
HasUserModel: Moved user method to trait
Diffstat (limited to 'src')
-rw-r--r--src/Models/User/HasUserModel.php18
-rw-r--r--src/Models/User/UsesUserModel.php25
2 files changed, 27 insertions, 16 deletions
diff --git a/src/Models/User/HasUserModel.php b/src/Models/User/HasUserModel.php
index 6d1323de..2b7fdda9 100644
--- a/src/Models/User/HasUserModel.php
+++ b/src/Models/User/HasUserModel.php
@@ -3,17 +3,11 @@
namespace Engelsystem\Models\User;
use Engelsystem\Models\BaseModel;
-use Illuminate\Database\Eloquent\Relations\BelongsTo;
-/**
- * @property integer $user_id
- *
- * @property-read \Illuminate\Database\Query\Builder|\Engelsystem\Models\User\User $user
- *
- * @method static \Illuminate\Database\Query\Builder|static whereUserId($value)
- */
abstract class HasUserModel extends BaseModel
{
+ use UsesUserModel;
+
/** @var string The primary key for the model */
protected $primaryKey = 'user_id';
@@ -24,12 +18,4 @@ abstract class HasUserModel extends BaseModel
/** The relationships that should be touched on save */
protected $touches = ['user'];
-
- /**
- * @return BelongsTo
- */
- public function user()
- {
- return $this->belongsTo(User::class);
- }
}
diff --git a/src/Models/User/UsesUserModel.php b/src/Models/User/UsesUserModel.php
new file mode 100644
index 00000000..84795480
--- /dev/null
+++ b/src/Models/User/UsesUserModel.php
@@ -0,0 +1,25 @@
+<?php
+
+namespace Engelsystem\Models\User;
+
+use Illuminate\Database\Eloquent\Relations\BelongsTo;
+
+/**
+ * @property integer $user_id
+ *
+ * @property-read \Illuminate\Database\Query\Builder|\Engelsystem\Models\User\User $user
+ *
+ * @method static \Illuminate\Database\Query\Builder|static whereUserId($value)
+ */
+trait UsesUserModel
+{
+ // protected $fillable = ['user_id'];
+
+ /**
+ * @return BelongsTo
+ */
+ public function user()
+ {
+ return $this->belongsTo(User::class);
+ }
+}