当前位置: 首页>>代码示例>>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;未经允许,请勿转载。