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


PHP File::findOrFail方法代碼示例

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


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

示例1: destroy

 public function destroy($id)
 {
     $file = File::findOrFail($id);
     $file->delete($id);
     Session::flash('message', 'Fue eliminado de nuestros registros.');
     return redirect()->route('expedientes.index');
 }
開發者ID:jonavargas,項目名稱:Sistema-Centralizaci-n,代碼行數:7,代碼來源:FileController.php

示例2: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $file = File::findOrFail($id);
     $this->authorize('delete', $file);
     Storage::delete($file->local_name);
     $file->delete();
     return redirect('/files');
 }
開發者ID:quantbm,項目名稱:RimDrive,代碼行數:14,代碼來源:FilesController.php

示例3: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     //
     $file = File::findOrFail($id);
     unlink($_SERVER['DOCUMENT_ROOT'] . $file->url);
     $file->delete();
     return 1;
 }
開發者ID:urbanix,項目名稱:contract-payments-demo,代碼行數:14,代碼來源:FileController.php

示例4: downloadFile

 /**
  * Download a single file by id.
  *
  * @param string|int $id
  * @return \Symfony\Component\HttpFoundation\BinaryFileResponse
  */
 public function downloadFile($id)
 {
     $file = File::findOrFail($id);
     if (($filesystem = Config::get('filesystems.default')) === 'local') {
         return response()->download($file->getAbsolutePath(), $file->name . '.' . $file->extension, ['Content-Type' => $file->mime]);
     } else {
         $fs = Storage::getDriver();
         if ($filesystem === 'rackspace') {
             $stream = fopen($fs->getAdapter()->getContainer()->getCdn()->getCdnUri() . '/' . $file->getRelativePath(), 'rb');
         } else {
             $stream = $fs->readStream($file->getRelativePath());
         }
         return Response::stream(function () use($stream) {
             fpassthru($stream);
         }, 200, ["Content-Type" => $fs->getMimetype($file->getRelativePath()), "Content-Length" => $fs->getSize($file->getRelativePath()), "Content-disposition" => "attachment; filename=\"" . $file->name . '.' . $file->extension . "\""]);
     }
 }
開發者ID:syntropysoftware,項目名稱:cryptoffice-frontend,代碼行數:23,代碼來源:ItemsDownloadController.php

示例5: findOrFail

 public function findOrFail($id)
 {
     return File::findOrFail($id);
 }
開發者ID:mnt,項目名稱:download-neptunium,代碼行數:4,代碼來源:EloquentFileRepository.php

示例6: update

 /**
  * 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 you need to validate any input.
     $file = File::findOrFail($id);
     $file->update($request->all());
     return redirect('file');
 }
開發者ID:DurvalNascimento,項目名稱:desconsolidacao,代碼行數:13,代碼來源:FileController.php

示例7: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $data = File::findOrFail($id);
     $data->delete();
     return redirect('file')->with('status', 'Delete Complete');
 }
開發者ID:polodev,項目名稱:Bard-Ftfl-Laravel-Project,代碼行數:12,代碼來源:FileController.php

示例8: deleteSingleImage

 public function deleteSingleImage(Request $request)
 {
     $imageId = $request->input('id');
     try {
         DB::beginTransaction();
         // delete the file from the files table
         $file = File::findOrFail($imageId);
         $file->delete();
         // remove the entry from the gallery image pivot table
         DB::table('gallery_images')->where('file_id', $file->id)->delete();
         // delete the actual image from S3
         $fileName = str_replace(env('S3_URL'), '', $file->file_path);
         $fileName = explode('/', $fileName);
         $mainImage = "gallery_{$request->input('galleryId')}/main/" . $fileName[count($fileName) - 1];
         $thumbImage = "gallery_{$request->input('galleryId')}/thumb/" . $fileName[count($fileName) - 1];
         $mediummage = "gallery_{$request->input('galleryId')}/medium/" . $fileName[count($fileName) - 1];
         $s3 = Storage::disk('s3');
         $s3->delete($mainImage);
         $s3->delete($thumbImage);
         $s3->delete($mediummage);
         DB::commit();
     } catch (\PDOException $e) {
         DB::rollBack();
     }
     return response($this->show($request->input('galleryId')), 200);
 }
開發者ID:worldmc,項目名稱:learningl5,代碼行數:26,代碼來源:GalleryController.php

示例9: imagesDelete

 public function imagesDelete(Request $request)
 {
     File::findOrFail($request->input('id'))->delete();
 }
開發者ID:emadmrz,項目名稱:Hawk,代碼行數:4,代碼來源:ShopController.php

示例10: format

 /**
  * @param $file_id
  * @return mixed
  */
 public function format($file_id)
 {
     return File::findOrFail($file_id)->format;
 }
開發者ID:dericcain,項目名稱:psa,代碼行數:8,代碼來源:FileRepository.php

示例11: update

 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $file = File::findOrFail($id);
     // $old_path = public_path($file->path);
     $file->name = $request->file_name;
     $file->slug = '@' . str_slug($request->file_name);
     try {
         $file->save();
         // $new_path = public_path('documents/'.$folder->user()->first()->slug.'/'.current_folder_path(Folder::find($folder->parent_folder_id)).'/'.$folder->slug);
         // \File::move($old_path, $new_path);
     } catch (\Exception $e) {
         return response()->json(['message' => 'File was not updated', 'description' => $e->getMessage()], 403);
     }
     return response()->json(['message' => 'File updated correctly', 'description' => 'File updated correctly'], 201);
 }
開發者ID:raffe90,項目名稱:gestoria-d-d,代碼行數:22,代碼來源:FilesController.php


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