public static function removeFile($id) { $file = MaterialFile::findorfail($id); $material = $file->materials; MaterialFileController::destroyFile($file->filename); $thumb = 'thumbs/' . pathinfo($file->filename, PATHINFO_FILENAME) . '.jpg'; MaterialFileController::destroyFile($thumb); $file->delete($id); Session::flash('warning', 'You have successfully deleted' . $file->filename); return redirect()->back()->with('material', 'material'); }
public static function download($file_id) { $file = MaterialFile::findorfail($file_id); $pathToFile = storage_path() . '/app/' . $file->filename; return response()->download($pathToFile); }