| @@ 203-217 (lines=15) @@ | ||
| 200 | * @param string $id |
|
| 201 | * @return \Illuminate\Http\RedirectResponse |
|
| 202 | */ |
|
| 203 | public function destroy($id) |
|
| 204 | { |
|
| 205 | $device = Device::withTrashed()->findOrFail($id); |
|
| 206 | ||
| 207 | if ($device->trashed()) { |
|
| 208 | //If the device was already deleted then permanently delete it |
|
| 209 | $device->forceDelete($device->id); |
|
| 210 | } else { |
|
| 211 | //Soft delete the device the first time |
|
| 212 | $device->delete(); |
|
| 213 | } |
|
| 214 | ||
| 215 | return redirect()->route('device.index') |
|
| 216 | ->with('success','Device deleted successfully'); |
|
| 217 | } |
|
| 218 | ||
| 219 | /** |
|
| 220 | * Restores a device. |
|
| @@ 144-158 (lines=15) @@ | ||
| 141 | * @param string $id |
|
| 142 | * @return \Illuminate\Http\RedirectResponse |
|
| 143 | */ |
|
| 144 | public function destroy($id) |
|
| 145 | { |
|
| 146 | $user = User::withTrashed()->findOrFail($id); |
|
| 147 | ||
| 148 | if ($user->trashed()) { |
|
| 149 | //If the user was already deleted then permanently delete it |
|
| 150 | $user->forceDelete($user->id); |
|
| 151 | } else { |
|
| 152 | //Soft delete the user the first time |
|
| 153 | $user->delete(); |
|
| 154 | } |
|
| 155 | ||
| 156 | return redirect()->route('user.index') |
|
| 157 | ->with('success','User deleted successfully'); |
|
| 158 | } |
|
| 159 | ||
| 160 | /** |
|
| 161 | * Restores a user. |
|