Code Duplication    Length = 17-23 lines in 2 locations

app/Http/Controllers/DeviceController.php 1 location

@@ 175-197 (lines=23) @@
172
     * @param  string  $id
173
     * @return \Illuminate\Http\RedirectResponse
174
     */
175
    public function destroy($id)
176
    {
177
        $this->authorize('destroy', Device::class);
178
        
179
        $device = Device::withTrashed()->findOrFail($id);
180
181
        if ($device->trashed())
182
        {
183
            //If the device was already deleted then permanently delete it
184
            $device->forceDelete($device->id);
185
        } else
186
        {
187
            //Remove the location from the device
188
            $device->location_id = null;
189
            $device->save();
190
            
191
            //Soft delete the device the first time
192
            $device->delete();
193
        }
194
195
        return redirect()->route('device.index')
196
            ->with('success', 'Device deleted successfully');
197
    }
198
    
199
    /**
200
     * Restores a device.

app/Http/Controllers/UserController.php 1 location

@@ 159-175 (lines=17) @@
156
     * @param  string  $id
157
     * @return \Illuminate\Http\RedirectResponse
158
     */
159
    public function destroy($id)
160
    {
161
        $this->authorize('destroy', User::class);
162
        
163
        $user = User::withTrashed()->findOrFail($id);
164
165
        if ($user->trashed()) {
166
            //If the user was already deleted then permanently delete it
167
            $user->forceDelete($user->id);
168
        } else {
169
            //Soft delete the user the first time
170
            $user->delete();
171
        }
172
173
        return redirect()->route('user.index')
174
            ->with('success', 'User deleted successfully');
175
    }
176
    
177
    /**
178
     * Restores a user.