Code Duplication    Length = 32-32 lines in 2 locations

app/Http/Controllers/GuestController.php 1 location

@@ 70-101 (lines=32) @@
67
    }
68
69
    // TODO
70
    public function showAddEditForm($id = null)
71
    {
72
        if ($id === null) {
73
            $dataset = new Guest();
74
            $title = trans('general.add');
75
            $submitRoute = route($this->getRouteName().'.postadd');
76
        } else {
77
            try {
78
                $dataset = Guest::select('id', 'first_name', 'last_name', 'address', 'zip_code', 'place', 'PESEL', 'contact')->findOrFail($id);
79
            } catch (ModelNotFoundException $e) {
80
                return Controller::returnBack([
81
                    'message'     => trans('general.object_not_found'),
82
                    'alert-class' => 'alert-danger',
83
                ]);
84
            }
85
86
            $title = trans('general.edit');
87
            $submitRoute = route($this->getRouteName().'.postedit', $id);
88
        }
89
90
        $title .= ' '.mb_strtolower(trans('general.guest'));
91
92
        $viewData = [
93
            'dataset'     => $dataset,
94
            'fields'      => $this->getFields(),
95
            'title'       => $title,
96
            'submitRoute' => $submitRoute,
97
            'routeName'   => $this->getRouteName(),
98
        ];
99
100
        return view('addedit', $viewData);
101
    }
102
103
    // TODO
104
    private function getFields()

app/Http/Controllers/RoomController.php 1 location

@@ 67-98 (lines=32) @@
64
        return response()->json($data);
65
    }
66
67
    public function showAddEditForm($id = null)
68
    {
69
        if ($id === null) {
70
            $dataset = new Room();
71
            $title = trans('general.add');
72
            $submitRoute = route($this->getRouteName().'.postadd');
73
        } else {
74
            try {
75
                $dataset = Room::select('id', 'number', 'floor', 'capacity', 'price', 'comment')->findOrFail($id);
76
            } catch (ModelNotFoundException $e) {
77
                return Controller::returnBack([
78
                    'message'     => trans('general.object_not_found'),
79
                    'alert-class' => 'alert-danger',
80
                ]);
81
            }
82
83
            $title = trans('general.edit');
84
            $submitRoute = route($this->getRouteName().'.postedit', $id);
85
        }
86
87
        $title .= ' '.mb_strtolower(trans('general.room'));
88
89
        $viewData = [
90
            'dataset'     => $dataset,
91
            'fields'      => $this->getFields(),
92
            'title'       => $title,
93
            'submitRoute' => $submitRoute,
94
            'routeName'   => $this->getRouteName(),
95
        ];
96
97
        return view('addedit', $viewData);
98
    }
99
100
    private function getFields()
101
    {