Code Duplication    Length = 5-9 lines in 3 locations

app/Http/Controllers/DashboardController.php 1 location

@@ 32-40 (lines=9) @@
29
     */
30
    public function index(Request $request)
31
    {
32
        if (Gate::denies('index-dashboard'))
33
        {
34
            if (\Request::ajax()) {
35
                return response()->json("Please contact [email protected] to request access.", 403);
36
            } else {
37
                return redirect()->route('home')
38
                    ->with('failure', 'Please contact [email protected] to request access.');
39
            }
40
        }
41
        
42
        $request->validate([
43
            'site_id' => 'sometimes|required|integer|digits_between:1,10',

app/Http/Controllers/DeviceController.php 1 location

@@ 162-166 (lines=5) @@
159
        
160
        $device->save();
161
    
162
        if (\Request::ajax())
163
            return response()->json([ 'success' => 'Device updated successfully' ]);
164
        else
165
            return redirect()->route('device.show', $device->id)
166
                ->with('success', 'Device updated successfully');
167
    }
168
169
    /**

app/Http/Controllers/UserController.php 1 location

@@ 142-146 (lines=5) @@
139
140
        $user->save();
141
    
142
        if (\Request::ajax())
143
            return response()->json([ 'success' => 'Preferred device updated successfully' ]);
144
        else
145
            return redirect()->route('user.show', $user->id)
146
                ->with('success', 'User updated successfully');
147
    }
148
149
    /**