forked from ProcessMaker/processmaker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGroupMember.php
More file actions
140 lines (128 loc) · 4.1 KB
/
GroupMember.php
File metadata and controls
140 lines (128 loc) · 4.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<?php
namespace ProcessMaker\Models;
use ProcessMaker\Observers\GroupMemberObserver;
/**
* Represents a group Members definition.
*
* @property int $id
* @property int $group_id
* @property string $member_type
* @property int $member_id
* @property \Carbon\Carbon $updated_at
* @property \Carbon\Carbon $created_at
*
*
* @OA\Schema(
* schema="groupMembersEditable",
* @OA\Property(property="group_id", type="string", format="id"),
* @OA\Property(property="member_id", type="string", format="id"),
* @OA\Property(property="member_type", type="string"),
* @OA\Property(property="description", type="string"),
* ),
* @OA\Schema(
* schema="groupMembers",
* allOf={
* @OA\Schema(ref="#/components/schemas/groupMembersEditable"),
* @OA\Schema(
* type = "object",
* @OA\Property(property="id", type="string", format="id"),
* @OA\Property(property="created_at", type="string", format="date-time"),
* @OA\Property(property="updated_at", type="string", format="date-time"),
* )
* },
* ),
* @OA\Schema(
* schema="createGroupMembers",
* allOf={
* @OA\Schema(ref="#/components/schemas/groupMembersEditable"),
* @OA\Schema(
* type = "object",
* @OA\Property(property="id", type="string", format="id"),
* @OA\Property(property="group", type="object"),
* @OA\Property(property="member", type="object"),
* @OA\Property(property="created_at", type="string", format="date-time"),
* @OA\Property(property="updated_at", type="string", format="date-time"),
* )
* },
* ),
* @OA\Schema(
* schema="getGroupMembersById",
* allOf={
* @OA\Schema(
* type = "object",
* @OA\Property(property="group_id", type="string", format="id"),
* @OA\Property(property="member_id", type="string", format="id"),
* @OA\Property(property="member_type", type="string"),
* @OA\Property(property="id", type="string", format="id"),
* @OA\Property(property="created_at", type="string", format="date-time"),
* @OA\Property(property="updated_at", type="string", format="date-time"),
* )
* },
* ),
* @OA\Schema(
* schema="availableGroupMembers",
* allOf={
* @OA\Schema(
* type = "object",
* @OA\Property(property="id", type="string", format="id"),
* @OA\Property(property="description", type="string"),
* @OA\Property(property="name", type="string"),
* @OA\Property(property="status", type="string", enum={"ACTIVE", "INACTIVE"}),
* @OA\Property(property="created_at", type="string", format="date-time"),
* @OA\Property(property="updated_at", type="string", format="date-time"),
* )
* },
* ),
*/
class GroupMember extends ProcessMakerModel
{
protected $connection = 'processmaker';
protected $fillable = [
'group_id', 'member_id', 'member_type',
];
/**
* Disable soft deletes for this model since the table doesn't have deleted_at column
*/
public function getDeletedAtColumn()
{
return null;
}
/**
* Disable soft deletes for this model
*/
public static function bootSoftDeletes()
{
// Do nothing - disable soft deletes
}
/**
* Override the query builder to not use soft deletes
*/
public function newEloquentBuilder($query)
{
return new \Illuminate\Database\Eloquent\Builder($query);
}
public static function rules()
{
return [
'group_id' => 'required',
'member_id' => 'required',
'member_type' => 'required|in:' . User::class . ',' . Group::class,
];
}
public function member()
{
return $this->morphTo(null, null, 'member_id');
}
public function group()
{
return $this->belongsTo(Group::class);
}
/**
* Boot the model and register observers
*/
protected static function boot()
{
parent::boot();
static::observe(GroupMemberObserver::class);
}
}