@@ -55,16 +55,14 @@ public function mount(): void
5555 Gate::authorize ('update ' , $ project );
5656 $ this ->form ->setProject ($ project );
5757 $ this ->state_name = $ project ->state ->getValue ();
58- $ this ->posts = $ project ->posts ->map (function (ProjectPost $ post ) {
59- return [
60- 'id ' => $ post ->id ,
61- 'name ' => $ post ->name ,
62- 'bemerkung ' => $ post ->bemerkung ?? '' ,
63- 'einnahmen ' => $ post ->einnahmen ,
64- 'ausgaben ' => $ post ->ausgaben ,
65- 'titel_id ' => $ post ->titel_id ,
66- ];
67- });
58+ $ this ->posts = $ project ->posts ->map (fn (ProjectPost $ post ) => [
59+ 'id ' => $ post ->id ,
60+ 'name ' => $ post ->name ,
61+ 'bemerkung ' => $ post ->bemerkung ?? '' ,
62+ 'einnahmen ' => $ post ->einnahmen ,
63+ 'ausgaben ' => $ post ->ausgaben ,
64+ 'titel_id ' => $ post ->titel_id ,
65+ ]);
6866 $ this ->attachments = []; // FIXME: load Attachments
6967 }
7068 }
@@ -124,7 +122,7 @@ public function save()
124122 }
125123 DB ::commit ();
126124
127- return redirect ()-> route ('project.show ' , $ project ->id );
125+ return to_route ('project.show ' , $ project ->id );
128126 } catch (\Exception $ e ) {
129127 DB ::rollBack ();
130128 $ this ->addError ('save ' , 'Fehler beim Speichern: ' .$ e ->getMessage ());
@@ -176,19 +174,15 @@ public function addEmptyPost(): void
176174 */
177175 public function getTotalIncome (): Money
178176 {
179- return $ this ->posts ->reduce (function (?Money $ carry , array $ post ) {
180- return $ carry ? $ carry ->add ($ post ['einnahmen ' ]) : $ post ['einnahmen ' ];
181- }, Money::EUR (0 ));
177+ return $ this ->posts ->reduce (fn (?Money $ carry , array $ post ) => $ carry ? $ carry ->add ($ post ['einnahmen ' ]) : $ post ['einnahmen ' ], Money::EUR (0 ));
182178 }
183179
184180 /**
185181 * Get the sum of all expense posts
186182 */
187183 public function getTotalExpenses (): Money
188184 {
189- return $ this ->posts ->reduce (function (?Money $ carry , array $ post ) {
190- return $ carry ? $ carry ->add ($ post ['ausgaben ' ]) : $ post ['ausgaben ' ];
191- }, Money::EUR (0 ));
185+ return $ this ->posts ->reduce (fn (?Money $ carry , array $ post ) => $ carry ? $ carry ->add ($ post ['ausgaben ' ]) : $ post ['ausgaben ' ], Money::EUR (0 ));
192186 }
193187
194188 public function removeAttachment (int $ index ): void
@@ -216,16 +210,14 @@ protected function getRechtsgrundlagenOptions(): array
216210 {
217211 $ rechtsgrundlagen = config ('stufis.project_legal ' , []);
218212
219- return collect ($ rechtsgrundlagen )->map (function ($ def , $ key ) {
220- return [
221- 'key ' => $ key ,
222- 'label ' => $ def ['label ' ] ?? $ key ,
223- 'placeholder ' => $ def ['placeholder ' ] ?? '' ,
224- 'label_additional ' => $ def ['label-additional ' ] ?? 'Zusatzinformationen ' ,
225- 'hint ' => $ def ['hint-text ' ] ?? '' ,
226- 'has_additional ' => isset ($ def ['placeholder ' ], $ def ['label-additional ' ]),
227- ];
228- })->toArray ();
213+ return collect ($ rechtsgrundlagen )->map (fn ($ def , $ key ) => [
214+ 'key ' => $ key ,
215+ 'label ' => $ def ['label ' ] ?? $ key ,
216+ 'placeholder ' => $ def ['placeholder ' ] ?? '' ,
217+ 'label_additional ' => $ def ['label-additional ' ] ?? 'Zusatzinformationen ' ,
218+ 'hint ' => $ def ['hint-text ' ] ?? '' ,
219+ 'has_additional ' => isset ($ def ['placeholder ' ], $ def ['label-additional ' ]),
220+ ])->all ();
229221 }
230222
231223 /**
0 commit comments