jesperfiltenborg/nova-variable-field
Composer 安装命令:
composer require jesperfiltenborg/nova-variable-field
包简介
A Laravel Nova field has the opportunity to contain variable values.
关键字:
README 文档
README
This package will no longer be maintained. Please use https://github.com/spatie/nova-translatable as a replacement. If you do not like the different approach of the spatie package, feel free to fork this repository and release new versions of it.
Nova Translatable Field
Adds the ability to show and edit translated fields created with spatie/laravel-translatable package.
It will show up in the detail view like this:
And in the edit view like this:
Alternative with support for more field types
If you need support for more field types to be translated, take a look at the official package from spatie: https://github.com/spatie/nova-translatable
Installation and usage
You can require this package using composer:
composer require mrmonat/nova-translatable
You can add the field follows:
use MrMonat\Translatable\Translatable;
Translatable::make('Description'),
Make sure, that you have your Eloquent model setup correct:
- First, you need to add the
Spatie\Translatable\HasTranslations-trait. - Next, you should create a public property
$translatablewhich holds an array with all the names of attributes you wish to make translatable. - Finally, you should make sure that all translatable attributes are set to the
text-datatype in your database. If your database supportsjson-columns, use that.
Here's an example of a prepared model:
use Illuminate\Database\Eloquent\Model; use Spatie\Translatable\HasTranslations; class NewsItem extends Model { use HasTranslations; public $translatable = ['name']; }
Defining Locales
Locales can be defined via config file config/translatable.php (config file can be created via spatie/laravel-translatable package) by adding a locales array:
// config/translatable.php
return [
...
'locales' => [
'en' => 'English',
'de' => 'German',
'fr' => 'French',
],
];
Alternatively you can "override" the config locales with the locales(...) method:
Translatable::make('Description')->locales([
'en' => 'English',
'de' => 'German',
]),
Single Line Option
By default the input field on the edit view is a textarea. If you want to change it to a single line input field you can add the singleLine() option:
Translatable::make('Description')->locales([...])->singleLine(),
Trix Editor
You can use the trix editor for your translated fields by using the trix() option:
Translatable::make('Description')->trix(),
Index View
By default the locale used when displaying the field on the index view is determined by app()->getLocale(). To override this you can use the indexLocale($locale) option:
Translatable::make('Description')->indexLocale('de'),
jesperfiltenborg/nova-variable-field 适用场景与选型建议
jesperfiltenborg/nova-variable-field 是一款 基于 Vue 开发的 Composer 扩展包,目前已累计 6 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 01 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「translatable」 「nova」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 jesperfiltenborg/nova-variable-field 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 jesperfiltenborg/nova-variable-field 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 jesperfiltenborg/nova-variable-field 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Laravel Nova card that shows you your system information.
A Laravel Nova card.
A Laravel Eloquent model trait for translatable resource
An Astrotomic Translatable extension for Laravel Nova.
A Laravel Nova package for publishable fields
Doctrine2 behavior traits - slowhop fork
统计信息
- 总下载量: 6
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-01-17