|
@@ -10,6 +10,8 @@ namespace App\Models;
|
|
|
|
|
|
class UserMessage extends BaseModel
|
|
class UserMessage extends BaseModel
|
|
{
|
|
{
|
|
|
|
+ protected $appends = ['product_type'];
|
|
|
|
+
|
|
public static function saveMessage($user_id, $type, $relation_id = 0, $param = [], $content = '')
|
|
public static function saveMessage($user_id, $type, $relation_id = 0, $param = [], $content = '')
|
|
{
|
|
{
|
|
if (empty($content)) {
|
|
if (empty($content)) {
|
|
@@ -25,4 +27,13 @@ class UserMessage extends BaseModel
|
|
|
|
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public function getProductTypeAttribute()
|
|
|
|
+ {
|
|
|
|
+ if (in_array($this->type, [1,2,4,5,6,7,8]) && !empty($this->relation_id)) {
|
|
|
|
+ return Order::where('id', $this->relation_id)->value('product_type');
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
}
|
|
}
|