Conditions | 4 |
Paths | 3 |
Total Lines | 20 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 15 |
CRAP Score | 4 |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
11 | 3 | public function __invoke(Request $request) |
|
12 | { |
||
13 | 3 | $formClass = Form::getClassByType($request->input(config('forms-entries.routing.form_name_parameter'))); |
|
14 | 3 | if (is_a($formClass, Form::class, true)) { |
|
15 | 2 | $formEntry = $formClass::make()->process($request); |
|
16 | 2 | if ($request->expectsJson()) { |
|
17 | 1 | return Response::json([ |
|
18 | 1 | 'message' => trans('forms-entries::messages.form_sent'), |
|
19 | 1 | 'data' => [ |
|
20 | 1 | 'type' => (string) (class_exists($formEntry->type)) ? class_basename($formEntry->type) : $formEntry->type, |
|
21 | 1 | 'saved' => (bool) $formEntry->exists, |
|
22 | 1 | 'notified' => (bool) $formEntry->notified_at, |
|
23 | 1 | ], |
|
24 | 1 | ]); |
|
25 | } |
||
26 | |||
27 | 1 | return redirect()->back()->with('success', trans('forms-entries::messages.form_sent')); |
|
28 | } |
||
29 | |||
30 | 1 | abort(404); |
|
31 | } |
||
33 |