Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵增煜
/
tzt-admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
6985b8b4
authored
Nov 11, 2024
by
lujunyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
药品标签
parent
df03af20
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
93 additions
and
4 deletions
+93
-4
app/Admin/Controllers/DrugController.php
+10
-3
app/Admin/Controllers/DrugTagController.php
+1
-1
app/Admin/Repositories/DrugRelatedTagRepository.php
+16
-0
app/Models/DrugModel.php
+10
-0
app/Models/DrugRelatedTagModel.php
+13
-0
database/migrations/2024_11_11_172239_create_drug_related_tag_table.php
+30
-0
lang/zh_CN/drug-related-tag.php
+13
-0
No files found.
app/Admin/Controllers/DrugController.php
View file @
6985b8b4
...
...
@@ -4,6 +4,7 @@
use
App\Admin\Repositories\DrugRepository
;
use
App\Models\DrugModel
;
use
App\Models\DrugTagModel
;
use
Dcat\Admin\Form
;
use
Dcat\Admin\Grid
;
use
Dcat\Admin\Http\Controllers\AdminController
;
...
...
@@ -97,7 +98,7 @@ protected function detail($id)
*/
protected
function
form
()
{
return
Form
::
make
(
new
DrugRepository
(),
function
(
Form
$form
)
{
return
Form
::
make
(
new
DrugRepository
(
'tag'
),
function
(
Form
$form
)
{
$form
->
display
(
'id'
)
->
width
(
4
);
$form
->
text
(
'name'
)
->
width
(
4
)
->
required
();
$form
->
hidden
(
'code'
)
->
width
(
4
)
->
required
();
...
...
@@ -110,8 +111,14 @@ protected function form()
$limitOption
=
array_combine
(
$array
,
$array
);
$form
->
select
(
'limit_buy_7'
)
->
placeholder
(
'请选择限购数量'
)
->
width
(
4
)
->
options
(
$limitOption
)
->
help
(
'限购数量'
);
$form
->
switch
(
'is_rx'
)
->
width
(
4
);
$form
->
text
(
'tag'
)
->
width
(
4
);
$form
->
text
(
'standard_code'
)
->
width
(
4
);
$form
->
text
(
'standard_code'
)
->
width
(
4
)
->
required
();
$form
->
multipleSelect
(
'tag'
,
'标签'
)
->
options
(
function
()
{
return
DrugTagModel
::
all
()
->
pluck
(
'tag_name'
,
'id'
);
})
->
customFormat
(
function
(
$v
)
{
return
array_column
(
$v
,
'id'
);
})
->
width
(
4
);
$form
->
display
(
'created_at'
)
->
width
(
4
);
$form
->
display
(
'updated_at'
)
->
width
(
4
);
...
...
app/Admin/Controllers/DrugTagController.php
View file @
6985b8b4
...
...
@@ -77,7 +77,7 @@ protected function form()
})
->
customFormat
(
function
(
$v
)
{
return
array_column
(
$v
,
'id'
);
});
})
->
width
(
4
)
;
$form
->
display
(
'created_at'
)
->
width
(
4
);
$form
->
display
(
'updated_at'
)
->
width
(
4
);
...
...
app/Admin/Repositories/DrugRelatedTagRepository.php
0 → 100755
View file @
6985b8b4
<?php
namespace
App\Admin\Repositories
;
use
App\Models\DrugRelatedTagModel
as
Model
;
use
Dcat\Admin\Repositories\EloquentRepository
;
class
DrugRelatedTagRepository
extends
EloquentRepository
{
/**
* Model.
*
* @var string
*/
protected
$eloquentClass
=
Model
::
class
;
}
app/Models/DrugModel.php
View file @
6985b8b4
...
...
@@ -31,4 +31,14 @@ public function setCodeAttribute($value)
$abbr
=
$pinyin
->
abbr
(
$this
->
name
)
->
join
(
''
);
// 获取拼音首字母
$this
->
attributes
[
'code'
]
=
strtoupper
(
$abbr
);
}
// 药品标签关联问诊问题,多对多
public
function
tag
()
{
$relatedModel
=
DrugTagModel
::
class
;
// 药品要关联的标签模型类名
$pivotTable
=
'drug_related_tag'
;
// 药品和标签关联中间表
return
$this
->
belongsToMany
(
$relatedModel
,
$pivotTable
,
'drug_id'
,
'tag_id'
)
->
withTimestamps
();
}
}
app/Models/DrugRelatedTagModel.php
0 → 100755
View file @
6985b8b4
<?php
namespace
App\Models
;
use
Dcat\Admin\Traits\HasDateTimeFormatter
;
use
Illuminate\Database\Eloquent\Model
;
class
DrugRelatedTagModel
extends
Model
{
use
HasDateTimeFormatter
;
protected
$table
=
'drug_related_tag'
;
}
database/migrations/2024_11_11_172239_create_drug_related_tag_table.php
0 → 100644
View file @
6985b8b4
<?php
use
Illuminate\Database\Migrations\Migration
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Support\Facades\Schema
;
return
new
class
extends
Migration
{
/**
* Run the migrations.
*/
public
function
up
()
:
void
{
Schema
::
create
(
'drug_related_tag'
,
function
(
Blueprint
$table
)
{
$table
->
comment
(
'药品和标签关联表'
);
$table
->
bigIncrements
(
'id'
);
$table
->
bigInteger
(
'drug_id'
)
->
comment
(
'药品ID'
);
$table
->
bigInteger
(
'tag_id'
)
->
comment
(
'标签ID'
);
$table
->
timestamps
();
});
}
/**
* Reverse the migrations.
*/
public
function
down
()
:
void
{
Schema
::
dropIfExists
(
'drug_related_tag'
);
}
};
lang/zh_CN/drug-related-tag.php
0 → 100755
View file @
6985b8b4
<?php
return
[
'labels'
=>
[
'DrugRelatedTag'
=>
'药品关联标签'
,
'drug-related-tag'
=>
'药品关联标签'
,
],
'fields'
=>
[
'drug_id'
=>
'药品ID'
,
'tag_id'
=>
'标签ID'
,
],
'options'
=>
[
],
];
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment