本文整理汇总了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');
}
示例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');
}
示例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;
}
示例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 . "\""]);
}
}
示例5: findOrFail
public function findOrFail($id)
{
return File::findOrFail($id);
}
示例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');
}
示例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');
}
示例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);
}
示例9: imagesDelete
public function imagesDelete(Request $request)
{
File::findOrFail($request->input('id'))->delete();
}
示例10: format
/**
* @param $file_id
* @return mixed
*/
public function format($file_id)
{
return File::findOrFail($file_id)->format;
}
示例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);
}