PluginProbe
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses / 1.0.93
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses v1.0.93
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 / Activity.php

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

99 lines 2.4 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\Models\XProfile;
6
7 /**
8 * Meta Model - DB Model for Notifications table
9 *
10 * Database Model
11 *
12 * @package FluentCommunity\App\Models
13 *
14 * @version 1.0.0
15 */
16 class Activity extends Model
17 {
18 protected $table = 'fcom_user_activities';
19
20 protected $primaryKey = 'id';
21
22 protected $guarded = ['id'];
23
24 protected $fillable = [
25 'user_id',
26 'feed_id',
27 'space_id',
28 'related_id',
29 'message',
30 'is_public',
31 'action_name'
32 ];
33
34 public static function boot()
35 {
36 parent::boot();
37 }
38
39 public function scopeByActions($query, $actions = [])
40 {
41 if (!empty($actions)) {
42 $query->whereIn('action_name', $actions);
43 }
44
45 return $query;
46 }
47
48 public function scopeBySpace($query, $spaceId)
49 {
50 if ($spaceId) {
51 return $query->where('space_id', $spaceId);
52 }
53
54 return $query->where('space_id', $spaceId);
55 }
56
57 public function feed()
58 {
59 return $this->belongsTo(Feed::class, 'feed_id');
60 }
61
62 public function space()
63 {
64 return $this->belongsTo(BaseSpace::class, 'space_id');
65 }
66
67 public function user()
68 {
69 return $this->belongsTo(User::class, 'user_id');
70 }
71
72 public function xprofile()
73 {
74 return $this->belongsTo(XProfile::class, 'user_id', 'user_id');
75 }
76
77 public function getFormattedMessage()
78 {
79 if (!$this->xprofile || !$this->feed) {
80 return '';
81 }
82
83 $message = '';
84
85 switch ($this->action_name) {
86 case 'feed_published':
87 /* translators: %1$s is the person name and %2$s is the feed excerpt */
88 $message = sprintf(__('%1$s published a new status %2$s', 'fluent-community'), '<span class="fcom_user_name">' . $this->xprofile->display_name . '</span>', '<span class="fcom_feed_excerpt">' . $this->feed->getHumanExcerpt() . '</span>');
89 break;
90 case 'comment_added':
91 /* translators: %1$s is the person name and %2$s is the feed excerpt */
92 $message = sprintf(__('%1$s added a comment on %2$s', 'fluent-community'), '<span class="fcom_user_name">' . $this->xprofile->display_name . '</span>', '<span class="fcom_feed_excerpt">' . $this->feed->getHumanExcerpt() . '</span>');
93 break;
94 }
95
96 return $message;
97 }
98 }
99