/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($id, Request $request) { //$this->validate($request, ['name' => 'required']); // Uncomment and modify if needed. $document = Document::findOrFail($id); $document->update($request->all()); return redirect('admin/documents')->with('success', Lang::get('message.success.update')); }
/** * Generate doc and download. * * @param int $id * @return \Illuminate\Http\Response */ public function download($id) { $document = Document::findOrFail($id); $phpWord = new PhpWord(); $template = public_path() . "/download/template.docx"; $file = public_path() . "/download/result.docx"; $download = $phpWord->loadTemplate($template); $download->setValue('COMPANY', $document->company); $download->setValue('OWNER', $document->owner); $download->saveAs($file); $headers = array('Content-Type: application/docx'); return response()->download($file, 'result.docx', $headers); }
public static function document($type, $data) { if ($type == 'id') { return Document::findOrFail($data); } return Document::where($type, $data)->first(); }
public function document_view($id) { $objDocument = \App\Document::findOrFail($id); $Filename = $objDocument->filename; if (!$this->objLoggedInUser->HasPermission("View/Documents") || !$Filename) { abort('404'); } $tmp = explode(".", $Filename); switch ($tmp[count($tmp) - 1]) { case "pdf": $ctype = "application/pdf"; break; case "exe": $ctype = "application/octet-stream"; break; case "zip": $ctype = "application/zip"; break; case "docx": case "doc": $ctype = "application/msword"; break; case "csv": case "xls": case "xlsx": $ctype = "application/vnd.ms-excel"; break; case "ppt": $ctype = "application/vnd.ms-powerpoint"; break; case "gif": $ctype = "image/gif"; break; case "png": $ctype = "image/png"; break; case "jpeg": case "jpg": $ctype = "image/jpg"; break; case "tif": case "tiff": $ctype = "image/tiff"; break; case "psd": $ctype = "image/psd"; break; case "bmp": $ctype = "image/bmp"; break; case "ico": $ctype = "image/vnd.microsoft.icon"; break; default: $ctype = "application/force-download"; } header("Content-type: {$ctype}"); // It will be called downloaded.pdf header("Content-Disposition:attachment;filename='{$Filename}'"); echo Storage::get("Documents/{$Filename}"); }