/** * Check for permissions and display the file. * * @author [A. Gianotto] [<*****@*****.**>] * @param int $assetId * @param int $fileId * @since [v1.0] * @return View */ public function displayFile($assetId = null, $fileId = null) { $asset = Asset::find($assetId); // the asset is valid if (isset($asset->id)) { if (!Company::isCurrentUserHasAccess($asset)) { return redirect()->to('hardware')->with('error', trans('general.insufficient_permissions')); } $log = Actionlog::find($fileId); $file = $log->get_src('assets'); $filetype = Helper::checkUploadIsImage($file); if ($filetype) { $contents = file_get_contents($file); return Response::make($contents)->header('Content-Type', $filetype); } else { return Response::download($file); } } else { // Prepare the error message $error = trans('admin/hardware/message.does_not_exist', compact('id')); // Redirect to the hardware management page return redirect()->route('hardware')->with('error', $error); } }