Commit 5768e19e by lujunyi

简码自动生成

parent 1ef99d93
......@@ -98,7 +98,7 @@ protected function form()
return Form::make(new DrugRepository(), function (Form $form) {
$form->display('id')->width(4);
$form->text('name')->width(4)->required();
$form->text('code')->width(4)->required();
$form->hidden('code')->width(4)->required();
$form->text('unit')->width(4)->required();
$form->text('spec')->width(4)->required();
$form->text('dosage_form')->width(4)->required();
......
......@@ -5,6 +5,7 @@
use Dcat\Admin\Traits\HasDateTimeFormatter;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Overtrue\Pinyin\Pinyin;
class DrugModel extends Model
{
......@@ -23,4 +24,11 @@ class DrugModel extends Model
self::RX_TRUE => '是',
self::RX_FALSE => '否',
];
public function setCodeAttribute($value)
{
$pinyin = new Pinyin();
$abbr = $pinyin->abbr($this->name)->join(''); // 获取拼音首字母
$this->attributes['code'] = strtoupper($abbr);
}
}
......@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "bbf64803dc3b06e15e1d478d97b9269f",
"content-hash": "44af1f9d3fa0d0609fd0179cfac581ec",
"packages": [
{
"name": "box/spout",
......@@ -3642,6 +3642,81 @@
"time": "2023-06-01T07:43:24+00:00"
},
{
"name": "overtrue/pinyin",
"version": "5.3.3",
"source": {
"type": "git",
"url": "https://github.com/overtrue/pinyin.git",
"reference": "bff15b27cf3e1cc416464b678576f4da9899692e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/overtrue/pinyin/zipball/bff15b27cf3e1cc416464b678576f4da9899692e",
"reference": "bff15b27cf3e1cc416464b678576f4da9899692e",
"shasum": ""
},
"require": {
"php": ">=8.0.2"
},
"require-dev": {
"brainmaestro/composer-git-hooks": "^3.0",
"friendsofphp/php-cs-fixer": "^3.2",
"laravel/pint": "^1.10",
"nunomaduro/termwind": "^1.0|^2.0",
"phpunit/phpunit": "^10.0|^11.2"
},
"bin": [
"bin/pinyin"
],
"type": "library",
"extra": {
"hooks": {
"pre-commit": [
"composer pint",
"composer test"
],
"pre-push": [
"composer pint",
"composer test"
]
}
},
"autoload": {
"psr-4": {
"Overtrue\\Pinyin\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "overtrue",
"email": "anzhengchao@gmail.com",
"homepage": "http://github.com/overtrue"
}
],
"description": "Chinese to pinyin translator.",
"homepage": "https://github.com/overtrue/pinyin",
"keywords": [
"Chinese",
"Pinyin",
"cn2pinyin"
],
"support": {
"issues": "https://github.com/overtrue/pinyin/issues",
"source": "https://github.com/overtrue/pinyin/tree/5.3.3"
},
"funding": [
{
"url": "https://github.com/overtrue",
"type": "github"
}
],
"time": "2024-08-01T08:19:06+00:00"
},
{
"name": "overtrue/qcloud-cos-client",
"version": "2.1.6",
"source": {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment