Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
ic_server_welfare
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
a26cd2df
authored
Aug 13, 2019
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
完成简单的积分类型信息增删改查
parent
8d7fc044
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
73 additions
and
2 deletions
app/Http/Controllers/IntegralTypesController.php
app/Http/Controllers/IntegralsController.php
app/Models/IntegralType.php
routes/web.php
app/Http/Controllers/IntegralTypesController.php
0 → 100644
View file @
a26cd2df
<?php
namespace
App\Http\Controllers
;
use
App\Models\IntegralType
;
use
Illuminate\Http\Request
;
use
Illuminate\Support\Facades\DB
;
class
IntegralTypesController
extends
Controller
{
public
function
index
()
{
$integrals
=
IntegralType
::
all
()
->
toArray
();
return
$this
->
Export
(
0
,
'ok'
,
[
'data'
=>
$integrals
]);
}
public
function
create
(
Request
$request
)
{
$res
=
DB
::
table
(
'integral_types'
)
->
insert
([
'name'
=>
$request
->
name
,
'add_time'
=>
time
(),
'status'
=>
1
,
]);
if
(
$res
)
{
return
$this
->
Export
(
0
,
'ok'
);
}
else
{
return
$this
->
Export
(
ErrorCode
(
011
,
5
),
'新增积分信息失败'
);
}
}
public
function
update
(
Request
$request
,
$id
)
{
$res
=
DB
::
table
(
'integral_types'
)
->
where
(
'id'
,
$id
)
->
update
([
'name'
=>
$request
->
name
,
'status'
=>
$request
->
status
,
]);
if
(
$res
)
{
return
$this
->
Export
(
0
,
'ok'
);
}
else
{
return
$this
->
Export
(
ErrorCode
(
012
,
5
),
'更新积分信息失败'
);
}
}
public
function
destroy
(
$ids
)
{
$ids
=
explode
(
','
,
trim
(
$ids
));
$res
=
DB
::
table
(
'integral_types'
)
->
whereIn
(
'id'
,
$ids
)
->
delete
();
if
(
$res
)
{
return
$this
->
Export
(
0
,
'ok'
);
}
else
{
return
$this
->
Export
(
ErrorCode
(
013
,
5
),
'删除积分信息失败'
);
}
}
}
\ No newline at end of file
app/Http/Controllers/IntegralsController.php
View file @
a26cd2df
...
@@ -12,7 +12,7 @@ class IntegralsController extends Controller
...
@@ -12,7 +12,7 @@ class IntegralsController extends Controller
{
{
public
function
index
()
public
function
index
()
{
{
$integrals
=
Integral
::
with
(
'integralType'
)
$integrals
=
Integral
::
with
(
'integralType
:id,name
'
)
->
whereStatus
(
1
)
->
whereStatus
(
1
)
->
get
()
->
toArray
();
->
get
()
->
toArray
();
...
@@ -51,7 +51,7 @@ class IntegralsController extends Controller
...
@@ -51,7 +51,7 @@ class IntegralsController extends Controller
public
function
destroy
(
$ids
)
public
function
destroy
(
$ids
)
{
{
$ids
=
explode
(
','
,
$ids
);
$ids
=
explode
(
','
,
trim
(
$ids
)
);
$res
=
DB
::
table
(
'integrals'
)
->
whereIn
(
'id'
,
$ids
)
->
delete
();
$res
=
DB
::
table
(
'integrals'
)
->
whereIn
(
'id'
,
$ids
)
->
delete
();
if
(
$res
)
{
if
(
$res
)
{
return
$this
->
Export
(
0
,
'ok'
);
return
$this
->
Export
(
0
,
'ok'
);
...
...
app/Models/IntegralType.php
View file @
a26cd2df
...
@@ -9,4 +9,6 @@ use Illuminate\Database\Eloquent\Model;
...
@@ -9,4 +9,6 @@ use Illuminate\Database\Eloquent\Model;
class
IntegralType
extends
Model
class
IntegralType
extends
Model
{
{
public
$timestamps
=
false
;
public
$timestamps
=
false
;
protected
$fillable
=
[
'name'
,
'status'
];
}
}
\ No newline at end of file
routes/web.php
View file @
a26cd2df
...
@@ -19,7 +19,14 @@ $router->get('/key', function () {
...
@@ -19,7 +19,14 @@ $router->get('/key', function () {
return
str_random
(
32
);
return
str_random
(
32
);
});
});
//积分信息
$router
->
get
(
'/integrals'
,
'IntegralsController@index'
);
$router
->
get
(
'/integrals'
,
'IntegralsController@index'
);
$router
->
post
(
'/integrals'
,
'IntegralsController@create'
);
$router
->
post
(
'/integrals'
,
'IntegralsController@create'
);
$router
->
patch
(
'/integrals/{id}'
,
'IntegralsController@update'
);
$router
->
patch
(
'/integrals/{id}'
,
'IntegralsController@update'
);
$router
->
delete
(
'/integrals/{id}'
,
'IntegralsController@destroy'
);
$router
->
delete
(
'/integrals/{id}'
,
'IntegralsController@destroy'
);
//积分类型
$router
->
get
(
'/integral_types'
,
'IntegralTypesController@index'
);
$router
->
post
(
'/integral_types'
,
'IntegralTypesController@create'
);
$router
->
patch
(
'/integral_types/{id}'
,
'IntegralTypesController@update'
);
$router
->
delete
(
'/integral_types/{id}'
,
'IntegralTypesController@destroy'
);
\ 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