Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
孙龙
/
note-library
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
76355e8a
authored
May 12, 2020
by
孙龙
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
up
parent
2d39b246
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
84 additions
and
1 deletions
app/Http/Controllers/AjaxController.php
app/Http/Controllers/WebController.php
app/Model/TemplateExtendModel.php
app/Http/Controllers/AjaxController.php
View file @
76355e8a
...
...
@@ -8,6 +8,7 @@ use DB;
use
App\Model\TemplateListModel
;
use
App\Model\SaleOrderListsModel
;
use
App\Model\TmplRelationsModel
;
use
App\Model\TemplateExtendModel
;
Class
AjaxController
extends
Controller
{
...
...
@@ -159,4 +160,64 @@ Class AjaxController extends Controller
}
}
/*
* 添加模板
*/
public
function
add_template
(
$request
){
$template_name
=
$request
->
input
(
"designName"
,
''
);
$html
=
$request
->
input
(
"html"
,
''
);
$lableBg
=
$request
->
input
(
"lableBg"
,
''
);
$lableBorder
=
$request
->
input
(
"lableBorder"
,
''
);
$lableSize
=
$request
->
input
(
"lableSize"
,
''
);
if
(
!
$template_name
){
return
$this
->
ajaxReturn
(
-
1
,
"请填写模板名称!"
);
}
if
(
!
$html
){
return
$this
->
ajaxReturn
(
-
1
,
"模板标签是空!"
);
}
$attribute
[
"lableBg"
]
=
$lableBg
;
$attribute
[
"lableBorder"
]
=
$lableBorder
;
$attribute
[
"lableSize"
]
=
$lableSize
;
$data
[
'template_name'
]
=
$template_name
;
$data
[
'html'
]
=
$html
;
$data
[
'attribute'
]
=
$attribute
;
try
{
DB
::
Connection
(
"label"
)
->
transaction
(
function
()
use
(
$data
,
$request
)
{
//创建模板
$templateList
=
TemplateListModel
::
create
([
"template_name"
=>
$data
[
'$template_name'
],
"create_userid"
=>
$request
->
user
->
userId
,
"create_username"
=>
$request
->
user
->
name
,
"create_time"
=>
time
(),
"update_time"
=>
time
(),
]);
if
(
!
$templateList
){
throw
new
\Exception
(
"添加模板失败"
,
-
1
);
}
//创建模板扩展信息 属性
$templateExtend
=
TemplateExtendModel
::
create
([
"template_id"
=>
$templateList
->
id
,
"html"
=>
$data
[
'html'
],
"attribute"
=>
json_encode
(
$data
[
'attribute'
]),
]);
if
(
!
$templateExtend
){
throw
new
\Exception
(
"添加模板失败"
,
-
1
);
}
});
}
catch
(
\Exception
$e
){
return
$this
->
ajaxReturn
(
-
1
,
"添加模板失败"
);
}
}
}
\ No newline at end of file
app/Http/Controllers/WebController.php
View file @
76355e8a
...
...
@@ -84,7 +84,6 @@ class WebController extends Controller
public
function
design
(
$request
,
$info
){
$info
[
'title'
]
=
'标签设计'
;
return
view
(
'web'
,
$info
);
}
...
...
app/Model/TemplateExtendModel.php
0 → 100644
View file @
76355e8a
<?php
namespace
App\Model
;
use
Illuminate\Database\Eloquent\Model
;
use
Illuminate\Http\Request
;
class
TemplateExtendModel
extends
Model
{
protected
$connection
=
'label'
;
//库名
protected
$table
=
'template_extend'
;
protected
$primaryKey
=
'id'
;
//设置id
protected
$guarded
=
[
'id'
];
//设置字段黑名单
public
$timestamps
=
false
;
protected
$dateFormat
=
'Y-m-d H:i:s'
;
}
\ No newline at end of file
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