@@ -60,9 +60,11 @@ public function update($models, $id, Request $request)
6060
6161 $ input = $ request ->all ();
6262
63- foreach ($ model ::fields () as $ field ){
64- if (array_key_exists ($ field ->name , $ input )){
65- $ input [$ field ->name ] = $ field ->preProcessInput ($ input [$ field ->name ], $ request , $ model );
63+ if ($ model ::fields ()) {
64+ foreach ($ model ::fields () as $ field ) {
65+ if (array_key_exists ($ field ->name , $ input )) {
66+ $ input [$ field ->name ] = $ field ->preProcessInput ($ input [$ field ->name ], $ request , $ model );
67+ }
6668 }
6769 }
6870
@@ -84,9 +86,11 @@ public function update($models, $id, Request $request)
8486
8587 $ model ->update ($ input );
8688
87- foreach ($ model ::fields () as $ field ){
88- if (array_key_exists ($ field ->name , $ input )){
89- $ input [$ field ->name ] = $ field ->postProcessInput ($ input [$ field ->name ], $ request , $ model );
89+ if ($ model ::fields ()) {
90+ foreach ($ model ::fields () as $ field ) {
91+ if (array_key_exists ($ field ->name , $ input )) {
92+ $ input [$ field ->name ] = $ field ->postProcessInput ($ input [$ field ->name ], $ request , $ model );
93+ }
9094 }
9195 }
9296
@@ -110,9 +114,11 @@ public function store($models, Request $request)
110114
111115 $ input = $ request ->all ();
112116
113- foreach ($ TLAPModel ::fields () as $ field ){
114- if (array_key_exists ($ field ->name , $ input )){
115- $ input [$ field ->name ] = $ field ->preProcessInput ($ input [$ field ->name ], $ request );
117+ if ($ TLAPModel ::fields ()) {
118+ foreach ($ TLAPModel ::fields () as $ field ) {
119+ if (array_key_exists ($ field ->name , $ input )) {
120+ $ input [$ field ->name ] = $ field ->preProcessInput ($ input [$ field ->name ], $ request );
121+ }
116122 }
117123 }
118124
@@ -130,9 +136,11 @@ public function store($models, Request $request)
130136
131137 $ createdModel = $ TLAPModel ::create ($ input );
132138
133- foreach ($ createdModel ::fields () as $ field ){
134- if (array_key_exists ($ field ->name , $ input )){
135- $ input [$ field ->name ] = $ field ->postProcessInput ($ input [$ field ->name ], $ request , $ createdModel );
139+ if ($ createdModel ::fields ()) {
140+ foreach ($ createdModel ::fields () as $ field ) {
141+ if (array_key_exists ($ field ->name , $ input )) {
142+ $ input [$ field ->name ] = $ field ->postProcessInput ($ input [$ field ->name ], $ request , $ createdModel );
143+ }
136144 }
137145 }
138146
0 commit comments