PluginProbe
FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration / 1.21
FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration v1.21
2.0.15 2.0.12 2.0.10 2.0.4 2.0.1 2.0.0 1.95.3 1.95.2 1.95 1.91.6 trunk 1.11 1.12 1.13 1.20 1.21 1.22 1.23 1.30 1.31 1.32 1.35 1.40 1.41 1.45 All 41 releases
fluent-boards / app / Models / User.php

User.php in FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration 1.21, at app/Models/User.php

134 lines 3.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentBoards\App\Models;
4
5 use FluentBoards\App\Services\Constant;
6
7 class User extends Model
8 {
9 protected $table = 'users';
10
11 protected $primaryKey = 'ID';
12
13 protected $hidden = ['user_pass', 'user_activation_key'];
14
15 protected $appends = ['photo'];
16
17 /**
18 * Accessor to get dynamic photo attribute
19 * @return string
20 */
21 public function getPhotoAttribute()
22 {
23 return fluent_boards_user_avatar($this->attributes['user_email'], $this->attributes['display_name']);
24 }
25
26 public function tasks()
27 {
28 return $this->belongsToMany(
29 Task::class,
30 'fbs_relations',
31 'foreign_id',
32 'object_id'
33 )->withPivot('settings')
34 ->wherePivot('object_type', Constant::OBJECT_TYPE_USER_TASK_WATCH)
35 ->withTimestamps();
36 }
37
38 public function watchingTasks()
39 {
40 return $this->belongsToMany(
41 Task::class,
42 'fbs_relations',
43 'foreign_id',
44 'object_id'
45 )->withPivot('settings')
46 ->wherePivot('object_type', Constant::OBJECT_TYPE_USER_TASK_WATCH)
47 ->withTimestamps();
48 }
49
50 public function highPriorityTasks()
51 {
52 return $this->tasks()
53 ->where('is_archived', false)
54 ->where('parent_id', null)
55 ->where('priority', 'high')
56 ->take(3);
57 }
58
59 public function overDueTasks()
60 {
61 return $this->tasks()
62 ->where('is_archived', false)
63 ->where('parent_id', null)
64 ->overdue()
65 ->orderBy('due_date', 'ASC')
66 ->take(5);
67 }
68
69 public function upcomingTasks()
70 {
71 return $this->tasks()
72 ->where('is_archived', false)
73 ->where('parent_id', null)
74 ->upcoming()
75 ->orderBy('due_date', 'ASC')
76 ->take(3);
77 }
78
79 public function upcomingWithoutDuedate()
80 {
81 return $this->tasks()
82 ->where('is_archived', false)
83 ->where('parent_id', null)
84 ->whereNull('due_date')
85 ->orderBy('due_date', 'ASC')
86 ->take(3);
87 }
88
89 public function boards()
90 {
91 return $this->belongsToMany(
92 Board::class,
93 'fbs_relations',
94 'object_id',
95 'foreign_id'
96 )
97 ->wherePivot('object_type', 'board_user')
98 ->withTimestamps()
99 ->withPivot('settings', 'preferences');
100 }
101
102 public function whichBoards()
103 {
104 return $this->belongsToMany(
105 Board::class,
106 'fbs_relations',
107 'foreign_id',
108 'object_id'
109 )
110 ->wherePivot('object_type', Constant::OBJECT_TYPE_BOARD_USER)
111 ->withPivot('settings', 'preferences')
112 ->withTimestamps();
113 }
114
115
116 public function boardUser()
117 {
118 // return $this->hasMany(BoardUser::class);
119 return null;
120
121 }
122
123 public function notifications()
124 {
125 return $this->belongsToMany(
126 Notification::class,
127 'fbs_notification_users',
128 'user_id',
129 'notification_id'
130 )->withTimestamps()
131 ->withPivot('marked_read_at');
132 }
133 }
134