forked from ProcessMaker/processmaker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCategoryAssignment.php
More file actions
46 lines (39 loc) · 1.09 KB
/
CategoryAssignment.php
File metadata and controls
46 lines (39 loc) · 1.09 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
<?php
namespace ProcessMaker\Models;
use Illuminate\Database\Eloquent\Relations\Pivot;
class CategoryAssignment extends Pivot
{
public function setMorphType($type)
{
return $this;
}
public function setMorphClass($class)
{
return $this;
}
public static function boot()
{
parent::boot();
static::saved(function ($pivot) {
switch ($pivot->assignable_type) {
case Process::class:
//$pivot->assignable->process_category_id = $pivot->category->getKey();
break;
case Script::class:
//$pivot->assignable->script_category_id = $pivot->category->getKey();
break;
case Screen::class:
//$pivot->assignable->screen_category_id = $pivot->category->getKey();
break;
}
});
}
public function assignable()
{
return $this->morphTo('assignable');
}
public function category()
{
return $this->morphTo('category');
}
}