milebits / helpers
一个包含每个 Milebits 包助手函数的新 Laravel 包。
3.0.2
2022-02-10 14:25 UTC
Requires
- php: >=8.0
- laravel/framework: ^6|^7|^8|^9
Requires (Dev)
- orchestra/testbench: ^6.12
- phpunit/phpunit: ^9.5
README
一个包含每个 Milebits 包助手函数的新 Laravel 包。
如何安装
composer require milebits/helpers
可用方法
检查类中是否存在常量
use Illuminate\Support\Facades\Auth; use function Milebits\Helpers\Helpers\constExists; $exists = constExists("App\Models\User", 'constant'); $exists = constExists(Auth::user(), 'constant');
获取常量的值或获取默认值
use Illuminate\Support\Facades\Auth; use function Milebits\Helpers\Helpers\constVal; $value = constVal(Auth::user(), 'CONSTANT', 'default Value, can be anything'); $value = constVal("App\Models\User", 'CONSTANT', 'default Value, can be anything');
获取静态属性的值或获取默认值
use Illuminate\Support\Facades\Auth; use function Milebits\Helpers\Helpers\staticPropVal; $value = staticPropVal(Auth::user(), "StaticProp", 'default value'); $value = staticPropVal("App\Models\User", "StaticProp", 'default value');
获取属性的值或获取默认值
use Illuminate\Support\Facades\Auth; use function Milebits\Helpers\Helpers\propVal; $value = propVal(Auth::user(), 'Property', 'default value'); $value = propVal("App\Models\User", 'Property', 'default value');
检查类是否有特定的特质
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Support\Facades\Auth; use function Milebits\Helpers\Helpers\hasTrait; $hasSoftDeletes = hasTrait(Auth::user(), SoftDeletes::class); $hasSoftDeletes = hasTrait("App\Models\User", SoftDeletes::class);
将某物包裹在数组中
use function Milebits\Helpers\Helpers\array_wrap; $value = "test"; $array = ["arrayItem"]; $wrap = array_wrap($value); $wrap = array_wrap($array);
贡献
如果在使用此包的过程中,您想请求添加新功能,请通过suggestions@os.milebits.com联系我们,并提及您愿意贡献的包或建议的新功能。
漏洞
如果在使用此包的过程中,您遇到安全问题和安全漏洞,请尽快通过在 Github 上提交问题或通过发送电子邮件至security@os.milebits.com并提及主题 漏洞报告 milebits/helpers 来报告它们。