1 | <?php |
||
35 | class FormResponse extends Model |
||
36 | { |
||
37 | use ValidatingTrait; |
||
38 | |||
39 | /** |
||
40 | * {@inheritdoc} |
||
41 | */ |
||
42 | protected $fillable = [ |
||
43 | 'unique_identifier', |
||
44 | 'content', |
||
45 | 'form_id', |
||
46 | 'user_id', |
||
47 | 'user_type', |
||
48 | ]; |
||
49 | |||
50 | /** |
||
51 | * {@inheritdoc} |
||
52 | */ |
||
53 | protected $casts = [ |
||
54 | 'unique_identifier' => 'string', |
||
55 | 'content' => 'json', |
||
56 | 'form_id' => 'integer', |
||
57 | 'user_id' => 'integer', |
||
58 | 'user_type' => 'string', |
||
59 | 'deleted_at' => 'datetime', |
||
60 | ]; |
||
61 | |||
62 | /** |
||
63 | * {@inheritdoc} |
||
64 | */ |
||
65 | protected $observables = [ |
||
66 | 'validating', |
||
67 | 'validated', |
||
68 | ]; |
||
69 | |||
70 | /** |
||
71 | * The default rules that the model will validate against. |
||
72 | * |
||
73 | * @var array |
||
74 | */ |
||
75 | protected $rules = []; |
||
76 | |||
77 | /** |
||
78 | * Whether the model should throw a |
||
79 | * ValidationException if it fails validation. |
||
80 | * |
||
81 | * @var bool |
||
82 | */ |
||
83 | protected $throwValidationExceptions = true; |
||
84 | |||
85 | /** |
||
86 | * Create a new Eloquent model instance. |
||
87 | * |
||
88 | * @param array $attributes |
||
89 | */ |
||
90 | public function __construct(array $attributes = []) |
||
103 | |||
104 | /** |
||
105 | * Get the form response user. |
||
106 | * |
||
107 | * @return \Illuminate\Database\Eloquent\Relations\MorphTo |
||
108 | */ |
||
109 | public function user() |
||
113 | |||
114 | /** |
||
115 | * Get form responses of the given user. |
||
116 | * |
||
117 | * @param \Illuminate\Database\Eloquent\Builder $builder |
||
118 | * @param \Illuminate\Database\Eloquent\Model $user |
||
119 | * |
||
120 | * @return \Illuminate\Database\Eloquent\Builder |
||
121 | */ |
||
122 | public function scopeOfUser(Builder $builder, Model $user): Builder |
||
126 | |||
127 | /** |
||
128 | * The form response always belongs to a form. |
||
129 | * |
||
130 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
131 | */ |
||
132 | public function form(): BelongsTo |
||
136 | } |
||
137 |