ptuchik / core-utilities
Laravel 的核心工具,用于扩展一些功能并为其他相关包的项目做准备
1.0.42
2024-04-05 09:13 UTC
Requires
- illuminate/support: ^7.0|^8.0|^9.0|^10.0|^11.0
- intervention/image: *
- spatie/laravel-translatable: *
- dev-master
- 1.0.42
- 1.0.41
- 1.0.40
- 1.0.39
- 1.0.38
- 1.0.37
- 1.0.36
- 1.0.35
- 1.0.34
- 1.0.33
- 1.0.32
- 1.0.31
- 1.0.30
- 1.0.29
- 1.0.28
- 1.0.27
- 1.0.26
- 1.0.25
- 1.0.24
- 1.0.23
- 1.0.22
- 1.0.21
- 1.0.20
- 1.0.19
- 1.0.18
- 1.0.17
- 1.0.16
- 1.0.15
- 1.0.14
- 1.0.13
- 1.0.12
- 1.0.11
- 1.0.10
- 1.0.9
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- dev-develop
This package is auto-updated.
Last update: 2024-09-05 10:04:37 UTC
README
此包包含一些对 Laravel 5.5+ 有用的工具,用于扩展一些功能并为其他相关包的项目做准备
目前包含
class AbstractTypes
- 扩展此类并添加您自己的常量,以便稍后轻松使用。
用法
class Gender extends AbstractTypes { const MALE = 1; const FEMALE = 2; }
print_r(Gender::MALE); // Output: 1 print_r(Gender::FEMALE); // Output: 2 print_r(Gender::all()); // Output: '1,2' print_r(Gender::all('json')); // Output: '{"1":"translated.male","2":"translated.female"}' // You can also pass second parameter false, to not translate the values print_r(Gender::all('json', false)); // Output: '{"1":"MALE","2":"FEMALE"}' print_r(Gender::all('array')); // Output: ["MALE" => 1, "FEMALE" => 2]
class AppEngineCron
- 仅过滤并允许来自 Google AppEngine 的 CRON 的请求的中介层
用法
只需将其添加到您需要过滤的路由中
class ForceSSL
- 将 HTTP 请求转换为 HTTPS 的中介层(如果配置中已设置)
用法
编辑配置文件中的 protocol
参数并将其添加到您需要转换的路由中
class Handler
- 将异常转换为 RESTful 错误消息的转换器
用法
从此类扩展您的 App/Exceptions/Handler
,您将获得所有异常的 RESTful API 格式化
class Model
- 此类从原生 Eloquent 模型扩展并添加了一些有用的功能,例如 camelCase 属性、可翻译属性以及可选和可配置的属性清理
用法
从此类扩展所有您的模型,而不是原生 Illuminate\Database\Eloquent\Model
,您将自动获得它们
trait HasParams
- 您可以在所有具有数据库中params
属性的模型中使用此特质
不要忘记 在使用此特质之前将 params
属性转换为 array
trait HasIcon
- 您可以在所有具有图标的模型中使用此特质。这将添加$model->saveIcon($image);
和$model->deleteIcon();
方法。
不要忘记 在使用此特质之前将 icon
列添加到您模型表之前
class Storage
- 您可以用它作为您存储的工厂
用法
use Ptuchik\CoreUtilities\Helpers\Storage; $storage = new Storage(); // Pass true as the only parameter if you need to initialize your public storage // ... after initialization you can use $storage variable as regular Filesystem Adapter. like: $storage->get($path); $storage->put($path); // ...etc...