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
df03af20
authored
Nov 11, 2024
by
lujunyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
标签关联问题
parent
53bf8ceb
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
97 additions
and
3 deletions
+97
-3
app/Admin/Controllers/DrugTagController.php
+10
-3
app/Admin/Repositories/DrugTagInquiryRepository.php
+16
-0
app/Models/DrugTagInquiryModel.php
+18
-0
app/Models/DrugTagModel.php
+10
-0
database/migrations/2024_11_11_153233_create_drug_tag_inquiry_table.php
+30
-0
lang/zh_CN/drug-tag-inquiry.php
+13
-0
No files found.
app/Admin/Controllers/DrugTagController.php
View file @
df03af20
...
...
@@ -3,6 +3,7 @@
namespace
App\Admin\Controllers
;
use
App\Admin\Repositories\DrugTagRepository
;
use
App\Models\InquiryModel
;
use
Dcat\Admin\Form
;
use
Dcat\Admin\Grid
;
use
Dcat\Admin\Http\Controllers\AdminController
;
...
...
@@ -18,7 +19,7 @@ class DrugTagController extends AdminController
*/
protected
function
grid
()
{
return
Grid
::
make
(
new
DrugTagRepository
(),
function
(
Grid
$grid
)
{
return
Grid
::
make
(
new
DrugTagRepository
(
'inquiry'
),
function
(
Grid
$grid
)
{
$grid
->
model
()
->
orderBy
(
'id'
,
'DESC'
);
$grid
->
column
(
'id'
)
->
sortable
();
...
...
@@ -67,10 +68,16 @@ protected function detail($id)
*/
protected
function
form
()
{
return
Form
::
make
(
new
DrugTagRepository
(),
function
(
Form
$form
)
{
return
Form
::
make
(
new
DrugTagRepository
(
'inquiry'
),
function
(
Form
$form
)
{
$form
->
display
(
'id'
)
->
width
(
4
);
$form
->
text
(
'tag_name'
)
->
width
(
4
);
$form
->
multipleSelect
(
'inquiry'
,
'问诊问题'
)
->
options
(
function
()
{
return
InquiryModel
::
all
()
->
pluck
(
'question'
,
'id'
);
})
->
customFormat
(
function
(
$v
)
{
return
array_column
(
$v
,
'id'
);
});
$form
->
display
(
'created_at'
)
->
width
(
4
);
$form
->
display
(
'updated_at'
)
->
width
(
4
);
...
...
app/Admin/Repositories/DrugTagInquiryRepository.php
0 → 100755
View file @
df03af20
<?php
namespace
App\Admin\Repositories
;
use
App\Models\DrugTagInquiryModel
as
Model
;
use
Dcat\Admin\Repositories\EloquentRepository
;
class
DrugTagInquiryRepository
extends
EloquentRepository
{
/**
* Model.
*
* @var string
*/
protected
$eloquentClass
=
Model
::
class
;
}
app/Models/DrugTagInquiryModel.php
0 → 100755
View file @
df03af20
<?php
namespace
App\Models
;
use
Dcat\Admin\Traits\HasDateTimeFormatter
;
use
Illuminate\Database\Eloquent\Model
;
class
DrugTagInquiryModel
extends
Model
{
use
HasDateTimeFormatter
;
protected
$table
=
'drug_tag_inquiry'
;
protected
$fillable
=
[
'tag_id'
,
'inquiry_id'
,
];
}
app/Models/DrugTagModel.php
View file @
df03af20
...
...
@@ -12,4 +12,14 @@ class DrugTagModel extends Model
use
SoftDeletes
;
protected
$table
=
'drug_tag'
;
// 药品标签关联问诊问题,多对多
public
function
inquiry
()
{
$relatedModel
=
InquiryModel
::
class
;
// 药品标签要关联的问诊问题模型类名
$pivotTable
=
'drug_tag_inquiry'
;
// 药品标签和问诊问题关联中间表
return
$this
->
belongsToMany
(
$relatedModel
,
$pivotTable
,
'tag_id'
,
'inquiry_id'
)
->
withTimestamps
();
}
}
database/migrations/2024_11_11_153233_create_drug_tag_inquiry_table.php
0 → 100644
View file @
df03af20
<?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_tag_inquiry'
,
function
(
Blueprint
$table
)
{
$table
->
comment
(
'药品标签和问诊问题关联表'
);
$table
->
bigIncrements
(
'id'
);
$table
->
bigInteger
(
'tag_id'
)
->
comment
(
'药品标签ID'
);
$table
->
bigInteger
(
'inquiry_id'
)
->
comment
(
'问诊问题ID'
);
$table
->
timestamps
();
});
}
/**
* Reverse the migrations.
*/
public
function
down
()
:
void
{
Schema
::
dropIfExists
(
'drug_tag_inquiry'
);
}
};
lang/zh_CN/drug-tag-inquiry.php
0 → 100755
View file @
df03af20
<?php
return
[
'labels'
=>
[
'DrugTagInquiry'
=>
'药品标签关联问题'
,
'drug-tag-inquiry'
=>
'药品标签关联问题'
,
],
'fields'
=>
[
'tag_id'
=>
'药品标签ID'
,
'inquiry_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