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
889d5c2e
authored
Aug 14, 2019
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
完成积分账单的简单增删改查
parent
8f27898d
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
86 additions
and
2 deletions
app/Http/Controllers/IntegralBillsController.php
app/Models/IntegralBill.php
config/database.php
routes/web.php
app/Http/Controllers/IntegralBillsController.php
0 → 100644
View file @
889d5c2e
<?php
namespace
App\Http\Controllers
;
use
App\Models\IntegralBill
;
use
Illuminate\Http\Request
;
use
Illuminate\Support\Facades\DB
;
class
IntegralBillsController
extends
Controller
{
public
function
index
()
{
$integrals
=
IntegralBill
::
all
()
->
toArray
();
return
$this
->
Export
(
0
,
'ok'
,
[
'data'
=>
$integrals
]);
}
public
function
create
(
Request
$request
)
{
$res
=
DB
::
table
(
'integral_bills'
)
->
insert
([
'user_id'
=>
$request
->
user_id
,
'integral_amount'
=>
$request
->
integral_amount
,
'integral_id'
=>
$request
->
integral_id
,
'status'
=>
1
,
'add_time'
=>
time
(),
]);
if
(
$res
)
{
return
$this
->
Export
(
0
,
'ok'
);
}
else
{
return
$this
->
Export
(
ErrorCode
(
021
,
5
),
'新增积分账单失败'
);
}
}
public
function
update
(
Request
$request
,
$id
)
{
$res
=
DB
::
table
(
'integral_bills'
)
->
where
(
'id'
,
$id
)
->
update
([
'user_id'
=>
$request
->
user_id
,
'integral_amount'
=>
$request
->
integral_amount
,
'integral_id'
=>
$request
->
integral_id
,
'status'
=>
1
,
'update_time'
=>
time
(),
]);
if
(
$res
)
{
return
$this
->
Export
(
0
,
'ok'
);
}
else
{
return
$this
->
Export
(
ErrorCode
(
022
,
5
),
'更新积分账单失败'
);
}
}
public
function
destroy
(
$ids
)
{
$ids
=
explode
(
','
,
trim
(
$ids
));
$res
=
DB
::
table
(
'integral_bills'
)
->
whereIn
(
'id'
,
$ids
)
->
delete
();
if
(
$res
)
{
return
$this
->
Export
(
0
,
'ok'
);
}
else
{
return
$this
->
Export
(
ErrorCode
(
023
,
5
),
'删除积分账单失败'
);
}
}
}
\ No newline at end of file
app/Models/IntegralBill.php
0 → 100644
View file @
889d5c2e
<?php
namespace
App\Models
;
use
Illuminate\Database\Eloquent\Model
;
class
IntegralBill
extends
Model
{
public
$timestamps
=
false
;
}
\ No newline at end of file
config/database.php
View file @
889d5c2e
This diff is collapsed.
Click to expand it.
routes/web.php
View file @
889d5c2e
...
...
@@ -29,4 +29,10 @@ $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
$router
->
delete
(
'/integral_types/{id}'
,
'IntegralTypesController@destroy'
);
//用户积分账单
$router
->
get
(
'/integral_bills'
,
'IntegralBillsController@index'
);
$router
->
post
(
'/integral_bills'
,
'IntegralBillsController@create'
);
$router
->
patch
(
'/integral_bills/{id}'
,
'IntegralBillsController@update'
);
$router
->
delete
(
'/integral_bills/{id}'
,
'IntegralBillsController@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