當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Storage::drive方法代碼示例

本文整理匯總了PHP中Storage::drive方法的典型用法代碼示例。如果您正苦於以下問題:PHP Storage::drive方法的具體用法?PHP Storage::drive怎麽用?PHP Storage::drive使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Storage的用法示例。


在下文中一共展示了Storage::drive方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getFileSystem

 /**
  * 獲取Filesystem
  * @return Filesystem
  */
 public static function getFileSystem()
 {
     if (is_null(static::$driver)) {
         static::$driver = \Storage::drive('local');
     }
     return static::$driver;
 }
開發者ID:xjtuwangke,項目名稱:laravel-bundles,代碼行數:11,代碼來源:LocalStoredFile.php

示例2: postPdfInvoice

 public function postPdfInvoice()
 {
     $data = \Request::get("jsonData");
     $data = utf8_encode($data);
     $facturas = json_decode($data, true);
     //$view = $this->viewInvoice($facturas[0]);
     //return $view;
     /*Generamos ZIP*/
     $uid = uniqid();
     $zip = new \Chumper\Zipper\Zipper();
     $zip->make(storage_path() . "/app/tmp/{$uid}/facturas.zip");
     $tmpDir = "/tmp/{$uid}";
     $this->tmpDir = storage_path('app') . $tmpDir;
     /*Insertamos cada factura en el zip*/
     foreach ($facturas as $factura) {
         $view = $this->viewInvoice($factura);
         $view = str_replace("localhost:8080", "localhost", $view);
         $pdfContents = \PDF::loadHTML($view)->setPaper('a4')->setOption('margin-right', 0)->setOption('margin-bottom', 0)->setOption('margin-left', 0)->setOption('margin-top', 0)->output();
         $nombreFact = "factura-{$factura['id']['serfac']}-{$factura['id']['ejefac']}-{$factura['id']['numfac']}.pdf";
         $zip->addString($nombreFact, $pdfContents);
         $uidPdf = uniqid();
         \File::put($this->tmpDir . "/{$uidPdf}.pdf", $pdfContents);
         $this->invoicesToWebRefresh[$uidPdf] = $factura;
     }
     /*$return = $this->refreshWeb();
     
             if($return != "ok") {
                 die($return);
             }*/
     /*Cerramos ZIP, eliminamos temportal y  descargamos*/
     $zip->close();
     $response = \Response::make(file_get_contents(storage_path() . "/app/tmp/{$uid}/facturas.zip"));
     \Storage::drive("local")->deleteDirectory("tmp/{$uid}");
     $response->header('Content-Disposition', 'attachment; filename="facturas.zip"');
     $response->header('Content-Length', strlen($response->getOriginalContent()));
     \File::deleteDirectory(storage_path("app") . "/tmp/{$uid}");
     return $response;
 }
開發者ID:alvarobfdev,項目名稱:applog,代碼行數:38,代碼來源:ApiController.php

示例3: postExportPdf

 public function postExportPdf(Request $request)
 {
     $ids = null;
     if ($request->exists("checkall")) {
         $filter = !is_null($request->input('search')) ? $this->buildSearch() : '';
         $args["params"] = $filter;
         $rows = $this->model->getRows($args);
         foreach ($rows["rows"] as $row) {
             $ids[] = $row->id;
         }
     }
     if (!$ids) {
         $ids = $request->input('ids');
     }
     if (count($ids) > 0) {
         $uid = uniqid();
         $zip = new \Chumper\Zipper\Zipper();
         $zip->make(storage_path() . "/app/tmp/{$uid}/facturas.zip");
         foreach ($ids as $id) {
             $view = $this->getHtmlContent($id);
             $nombreFact = "factura-{$this->data['row']->serfac}-{$this->data['row']->ejefac}-{$this->data['row']->numfac}.pdf";
             $pdfContents = \PDF::loadHTML($view)->setPaper('a4')->setOption('margin-right', 0)->setOption('margin-bottom', 0)->setOption('margin-left', 0)->setOption('margin-top', 0)->output();
             $zip->addString($nombreFact, $pdfContents);
             $this->data['subgrid'] = isset($this->info['config']['subgrid']) ? $this->info['config']['subgrid'][0] : array();
         }
         $zip->close();
         $response = \Response::make(file_get_contents(storage_path() . "/app/tmp/{$uid}/facturas.zip"));
         $size = \Storage::drive("local")->size("tmp/{$uid}/facturas.zip");
         \Storage::drive("local")->deleteDirectory("tmp/{$uid}");
         $response->header('Content-Disposition', 'attachment; filename="facturas.zip"');
         $response->header('Content-Length', '$size');
         return $response;
     }
 }
開發者ID:alvarobfdev,項目名稱:applog,代碼行數:34,代碼來源:FacturaController.php


注:本文中的Storage::drive方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。