PluginProbe
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses / 2.10.01
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses v2.10.01
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
fluent-community / app / Models / Meta.php

Meta.php in FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses 2.10.01, at app/Models/Meta.php

63 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentCommunity\App\Models;
4
5 use FluentCommunity\App\Functions\Utility;
6
7 /**
8 * Meta Model - DB Model for Meta table
9 *
10 * Database Model
11 *
12 * @package FluentCommunity\App\Models
13 *
14 * @version 1.0.0
15 *
16 * @property int $id
17 * @property string|null $object_type
18 * @property int|null $object_id
19 * @property string|null $meta_key
20 * @property mixed $value
21 */
22 class Meta extends Model
23 {
24 protected $table = 'fcom_meta';
25
26 protected $primaryKey = 'id';
27
28 protected $guarded = ['id'];
29
30 protected $fillable = [
31 'object_type',
32 'object_id',
33 'meta_key',
34 'value'
35 ];
36
37 public function setValueAttribute($value)
38 {
39 $this->attributes['value'] = maybe_serialize($value);
40 }
41
42 public function getValueAttribute($value)
43 {
44 return Utility::safeUnserialize($value);
45 }
46
47 public function scopeByType($query, $type)
48 {
49 return $query->where('object_type', $type);
50 }
51
52 public function scopeByMetaKey($query, $key)
53 {
54 return $query->where('meta_key', $key);
55 }
56
57 public function scopeByObjectId($query, $objectId)
58 {
59 return $query->where('object_id', $objectId);
60 }
61
62 }
63