netflex/files
最新稳定版本:v6.7.3
Composer 安装命令:
composer require netflex/files
包简介
Netflex files library
README 文档
README
[READ ONLY] Subtree split of the Netflex Files component (see netflex/framework)
This package simplifies working with the Netflex Files API.
Installation
composer require netflex/files
Basic usage
The File class provides a fluent query builder to search for files.
<?php use Netflex\Files\File; $files = File::where('type', 'png') ->where('name', 'like', 'Hello*') ->where('created', '>=', '2021-11-01') ->all();
You can also retrieve a list of tags:
<?php use Netflex\Files\File; use Netflex\Query\Builder; $tags = File::tags(); // Or with a query callback: $tags = File::tags(function ($query) { return $query->where('related_customers', [10000, 10010]); }) // Or with a query builder: $query = new Builder; $tags = File::tags($query->where('type', ['jpg', 'png']));
Example, retrieving images tagged 'netflex':
<?php use Netflex\Files\File; $taggedImages = File::where('tags', 'netflex')->all();
Uploading new files
Netflex Files supports multiple methods for uploading a new file. The most performand is to use an uploaded file directly, as this will get streamed directly to the CDN. This is the fastest method.
<?php // $request is either a Form Request or an instance of Illuminate\Http\Request $file = $request->file('uploaded-file'); $uploadedFile = File::upload($file); // Uploaded to folder '0'. // You can also upload an external file like this $uploadedFile = File::upload('https://example.com/test.jpg'); // Or a base64 encoded file: $uploadedFile = File::upload('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z/C/HgAGgwJ/lK3Q6wAAAABJRU5ErkJggg==', [ 'name' => 'test.png' // Name is required in this case, as a default name cannot be infered ]);
Duplicating a file
<?php use Netflex\Files\File; $file = File::find(10000)->copy('new-name.png');
Generating image url's
The File class implements the Netflex\Pages\Contracts\MediaUrlResolvable contract. And so it can be used like any other File object from Netflex.
<?php use Netflex\Files\File; $file = File::find(10000); $url = media_url($file, 'my-preset-name'); // or $url = media_url($file, '200x200', MODE_FIT);
You can also pass this object to the corresponding Blade components
<x-picture :src="$file" preset="my-preset-name" /> <x-image :src="$file" preset="my-preset-name" />
统计信息
- 总下载量: 638
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-11-04