File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -59,7 +59,7 @@ public function new($id = null): string
59
59
*/
60
60
public function create (): RedirectResponse
61
61
{
62
- if ($ this ->model ->insert ($ this ->request -> getPost ())) {
62
+ if ($ this ->model ->insert ($ this ->getData ())) {
63
63
return redirect ()->to (site_url ('emails/templates ' ))->with ('success ' , 'Email template created. ' );
64
64
}
65
65
@@ -115,7 +115,7 @@ public function update($id = null): RedirectResponse
115
115
{
116
116
$ template = $ this ->getTemplate ($ id );
117
117
118
- if ($ this ->model ->update ($ template ->id , $ this ->request -> getPost ())) {
118
+ if ($ this ->model ->update ($ template ->id , $ this ->getData ())) {
119
119
return redirect ()->back ()->with ('success ' , 'Email template updated. ' );
120
120
}
121
121
@@ -181,4 +181,18 @@ public function send_commit($id = null): RedirectResponse
181
181
182
182
return redirect ()->back ()->withInput ()->with ('error ' , $ email ->printDebugger ([]));
183
183
}
184
+
185
+ /**
186
+ * Retrieves POST data safe for the database.
187
+ */
188
+ protected function getData (): array
189
+ {
190
+ $ data = $ this ->request ->getPost ();
191
+
192
+ if (array_key_exists ('parent_id ' , $ data )) {
193
+ $ data ['parent_id ' ] = empty ($ data ['parent_id ' ]) ? null : $ data ['parent_id ' ];
194
+ }
195
+
196
+ return $ data ;
197
+ }
184
198
}
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ class Template extends Entity
16
16
'deleted_at ' ,
17
17
];
18
18
protected $ casts = [
19
+ 'id ' => '?int ' ,
19
20
'parent_id ' => '?int ' ,
20
21
];
21
22
You can’t perform that action at this time.
0 commit comments