public function zip() { $task = Input::get('task', 'show'); if ($task == 'delete' && Input::has('id')) { return $this->deleteZip(Input::get('id')); } else { if ($task == 'show') { $data = $this->getData('Zip'); $data['zips'] = TFZip::where('state', '=', 'zipped')->get(); return view('zip', $data); } else { if ($task == 'deleteAll') { foreach (TFZip::where('state', '=', 'zipped') as $zip) { Storage::delete($zip->location); $zip->state = 'deleted'; $zip->save(); } return redirect()->route('zip'); } else { if ($task == 'download' && Input::has('id')) { $zip = TFZip::find(Input::get('id')); if ($zip != null) { return response()->download(storage_path('app/' . $zip->location)); } return redirect()->route('zip'); } } } } return redirect()->route('zip'); }