PluginProbe
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses / 2.10.0
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses v2.10.0
2.10.0 2.10.01 2.9.1 2.9.0 2.8.1 2.8.0 2.7.7 2.7.5 2.7.0 2.6.01 2.6.0 2.5.0 2.4.01 trunk 1.0.90 1.0.91 1.0.92 1.0.93 1.0.94 1.0.95 1.0.96 1.0.97 1.0.98 1.0.99 1.1.0 All 77 releases
← All changes | app/Models/SpaceUserPivot.php +31 -1 1.0.922.10.0 View file →
@@ -1,8 +1,9 @@
1 1 <?php
2 2
3 3 namespace FluentCommunity\App\Models;
4 4
5 +use FluentCommunity\App\Functions\Utility;
5 6 use FluentCommunity\App\Models\Model;
6 7 use FluentCommunity\App\Models\XProfile;
7 8
8 9 class SpaceUserPivot extends Model
@@ -14,9 +15,10 @@
14 15 protected $fillable = [
15 16 'space_id',
16 17 'user_id',
17 18 'status',
18 - 'role'
19 + 'role',
20 + 'meta'
19 21 ];
20 22
21 23 public function scopeBySpace($query, $spaceId)
22 24 {
@@ -54,5 +56,33 @@
54 56 public function space()
55 57 {
56 58 return $this->belongsTo(BaseSpace::class, 'space_id', 'id')->withoutGlobalScopes();
57 59 }
60 +
61 + public function setMetaAttribute($value)
62 + {
63 + $this->attributes['meta'] = maybe_serialize($value);
64 + }
65 +
66 + public function getMetaAttribute($value)
67 + {
68 + if (!$value) {
69 + return [];
70 + }
71 +
72 + if (is_string($value)) {
73 + $decodedMeta = json_decode($value, true);
74 + if (is_array($decodedMeta)) {
75 + $value = $decodedMeta;
76 + }
77 + }
78 +
79 + $value = Utility::safeUnserialize($value);
80 +
81 + if (!is_array($value)) {
82 + return [];
83 + }
84 +
85 + return $value;
86 + }
87 +
58 88 }