-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCustomFieldValue.php
78 lines (65 loc) · 1.51 KB
/
CustomFieldValue.php
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
<?php
namespace App\Models;
use Eloquent as Model;
/**
* Class CustomFieldValue
* @package App\Models
* @version July 24, 2018, 9:13 pm UTC
*
* @property \App\Models\CustomField customField
* @property string value
* @property integer custom_field_id
* @property string customizable_type
* @property integer customizable_id
*/
class CustomFieldValue extends Model
{
public $table = 'custom_field_values';
public $fillable = [
'value',
'view',
'custom_field_id',
'customizable_type',
'customizable_id'
];
/**
* The attributes that should be casted to native types.
*
* @var array
*/
protected $casts = [
'value' => 'string',
'view' => 'string',
'custom_field_id' => 'integer',
'customizable_type' => 'string',
'customizable_id' => 'integer'
];
/**
* Validation rules
*
* @var array
*/
public static $rules = [
'custom_field_id' => 'required|exists:custom_fields,id',
'customizable_type' => 'required',
'customizable_id' => 'required'
];
/**
* New Attributes
*
* @var array
*/
protected $appends = [
];
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
**/
public function customField()
{
return $this->belongsTo(\App\Models\CustomField::class, 'custom_field_id', 'id');
}
public function customizable()
{
return $this->morphTo();
}
}