Skip to content

Commit 74fb692

Browse files
committed
Deposit history
1 parent 92eac61 commit 74fb692

File tree

10 files changed

+162
-62
lines changed

10 files changed

+162
-62
lines changed

app/Deposit.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
namespace App;
44

55
use Illuminate\Database\Eloquent\Model;
6+
use App\Customer;
7+
use App\Plan;
68

79
class Deposit extends Model
810
{
@@ -14,6 +16,11 @@ class Deposit extends Model
1416

1517
public function owner()
1618
{
17-
return $this->belongsTo('App\Customer', 'cust_id', 'id');
19+
return $this->belongsTo(Customer::class, 'cust_id', 'id');
20+
}
21+
22+
public function plan()
23+
{
24+
return $this->belongsTo(Plan::class, 'plan_id', 'id');
1825
}
1926
}

app/Http/Controllers/DepositController.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ public function create(DepositRequest $request)
3838
Deposit::with('owner')->where('id', $deposit->id)->first()
3939
));
4040

41-
return response()->json([ 'msg' => 'Deposit successfully']);
41+
return response()->json($deposit->toArray());
42+
}
43+
44+
public function history()
45+
{
46+
return Deposit::with('plan')
47+
->where('cust_id', auth()->user()->id)
48+
->orderBy('created_at', 'desc')
49+
->get();
4250
}
4351
}

public/js/controllers/DepositController.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
angular.module('MetronicApp').controller('DepositController', [
22
'$scope',
33
'$anchorScroll',
4+
'$state',
45
'Restful',
5-
function($scope, $anchorScroll, Restful) {
6+
function($scope, $anchorScroll, $state, Restful) {
67
var vm = this;
78
vm.model = {
89
plan_id: null,
910
amount: null
1011
};
1112
vm.plans = [];
13+
vm.deposits = [];
1214

1315
vm.save = function(){
1416
if (!$scope.depositForm.$valid) {
@@ -18,10 +20,20 @@ angular.module('MetronicApp').controller('DepositController', [
1820
vm.loading = true;
1921

2022
Restful.save('api/deposit', vm.model).success(function(data){
23+
$state.go('deposit/history');
2124
}).finally(function () {
2225
vm.loading= false;
2326
});;
2427
};
28+
29+
vm.getHistory = function(params){
30+
Restful.get('api/deposit/history').success(function(data){
31+
data.forEach(function(el){
32+
vm.deposits.push(el);
33+
});
34+
});
35+
};
36+
2537
vm.getQrCode = function(params){
2638
Restful.get('api/qr/admin/bitcoin').success(function(data){
2739
vm.qrcode = data;
@@ -37,6 +49,7 @@ angular.module('MetronicApp').controller('DepositController', [
3749
}
3850
vm.getQrCode();
3951
vm.getPlans();
52+
vm.getHistory();
4053
$scope.$on('$viewContentLoaded', function() {});
4154

4255
}

public/js/main.js

Lines changed: 26 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,13 @@ MetronicApp.controller('FooterController', ['$scope', function($scope) {
139139
/* Setup Rounting For All Pages */
140140
MetronicApp.config(['$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider) {
141141
// Redirect any unmatched url
142-
$urlRouterProvider.otherwise("dashboard.html");
142+
$urlRouterProvider.otherwise("dashboard");
143143

144144
$stateProvider
145145

146146
// Dashboard
147147
.state('dashboard', {
148-
url: "/dashboard.html",
148+
url: "/dashboard",
149149
templateUrl: "views/dashboard.html",
150150
data: {pageTitle: 'User Dashboard'},
151151
controller: "DashboardController as vm",
@@ -165,7 +165,7 @@ MetronicApp.config(['$stateProvider', '$urlRouterProvider', function($stateProvi
165165

166166
// Blank Page
167167
.state('deposit', {
168-
url: "/deposit.html",
168+
url: "/deposit",
169169
templateUrl: "views/deposit.html",
170170
data: {pageTitle: 'Make Deposit'},
171171
controller: "DepositController as vm",
@@ -183,9 +183,28 @@ MetronicApp.config(['$stateProvider', '$urlRouterProvider', function($stateProvi
183183
}
184184
})
185185

186+
.state('deposit/history', {
187+
url: "/deposit/history",
188+
templateUrl: "views/deposit_history.html",
189+
data: {pageTitle: 'Deposit History'},
190+
controller: "DepositController as vm",
191+
resolve: {
192+
deps: ['$ocLazyLoad', function($ocLazyLoad) {
193+
return $ocLazyLoad.load({
194+
name: 'MetronicApp',
195+
insertBefore: '#ng_load_plugins_before', // load the above css files before a LINK element with this ID. Dynamic CSS files must be loaded between core and theme css files
196+
files: [
197+
'css-template/plan_style.css',
198+
'js/controllers/DepositController.js',
199+
]
200+
});
201+
}]
202+
}
203+
})
204+
186205
// AngularJS plugins
187206
.state('request_payment', {
188-
url: "/request_payment.html",
207+
url: "/request_payment",
189208
templateUrl: "views/request_payment.html",
190209
data: {pageTitle: 'Request Payment'},
191210
controller: "RequestPaymentController as vm",
@@ -201,33 +220,8 @@ MetronicApp.config(['$stateProvider', '$urlRouterProvider', function($stateProvi
201220
}
202221
})
203222

204-
// UI Select
205-
.state('deposit_list', {
206-
url: "/deposit_list.html",
207-
templateUrl: "views/deposit_list.html",
208-
data: {pageTitle: 'Deposit Information'},
209-
controller: "DepositListController",
210-
resolve: {
211-
deps: ['$ocLazyLoad', function($ocLazyLoad) {
212-
return $ocLazyLoad.load([{
213-
name: 'ui.select',
214-
insertBefore: '#ng_load_plugins_before', // load the above css files before '#ng_load_plugins_before'
215-
files: [
216-
'../assets/global/plugins/angularjs/plugins/ui-select/select.min.css',
217-
'../assets/global/plugins/angularjs/plugins/ui-select/select.min.js'
218-
]
219-
}, {
220-
name: 'MetronicApp',
221-
files: [
222-
'js/controllers/UISelectController.js'
223-
]
224-
}]);
225-
}]
226-
}
227-
})
228-
229223
.state('user_profile', {
230-
url: "/user_profile.html",
224+
url: "/user_profile",
231225
templateUrl: "views/user_profile.html",
232226
data: {pageTitle: 'User Profile'},
233227
controller: "UserProfileController as vm",
@@ -243,7 +237,7 @@ MetronicApp.config(['$stateProvider', '$urlRouterProvider', function($stateProvi
243237
}
244238
})
245239
.state('user_profile_edit', {
246-
url: "/user_profile_edit.html",
240+
url: "/user_profile_edit",
247241
templateUrl: "views/user_profile_edit.html",
248242
data: {pageTitle: 'Edit User Profile'},
249243
controller: "UserProfileEditController as vm",
@@ -259,7 +253,7 @@ MetronicApp.config(['$stateProvider', '$urlRouterProvider', function($stateProvi
259253
}
260254
})
261255
.state('change_password', {
262-
url: "/change_password.html",
256+
url: "/change_password",
263257
templateUrl: "views/user_change_password.html",
264258
data: {pageTitle: 'Change Password User Profile'},
265259
controller: "ChangePasswordController as vm",

public/tpl/header.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
<img alt="" class="img-circle" src="{{settings.layoutPath}}/img/avatar9.jpg" /> </a>
3939
<ul class="dropdown-menu dropdown-menu-default">
4040
<li>
41-
<a href="#/user_profile.html">
41+
<a href="#/user_profile">
4242
<i class="icon-user"></i> My Profile </a>
4343
</li>
4444
<li class="divider"> </li>

public/tpl/sidebar.html

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,23 @@ <h3>Last Login:</h3>
99

1010
</li>
1111
<li class="start nav-item">
12-
<a href="#/dashboard.html">
12+
<a href="#/dashboard">
1313
<i class="icon-home"></i>
1414
<span class="title">Dashboard</span>
1515
</a>
1616
</li>
1717
<li class="nav-item">
18-
<a href="#/deposit.html">
18+
<a href="#/deposit">
1919
<i class="icon-wrench"></i>
2020
<span class="title">Make Deposit</span>
2121
</a>
2222
</li>
2323
<li class="nav-item">
24-
<a href="#/request_payment.html">
24+
<a href="#/request_payment">
2525
<i class="icon-user"></i>
2626
<span class="title">Request Payment</span>
2727
</a>
2828
</li>
29-
<li class="nav-item">
30-
<a href="#/deposit_list.html">
31-
<i class="icon-check"></i>
32-
<span class="title">Deposit List</span>
33-
</a>
34-
</li>
3529
<li class="nav-item">
3630
<a href="javascript:;">
3731
<i class="icon-settings"></i>
@@ -40,36 +34,36 @@ <h3>Last Login:</h3>
4034
</a>
4135
<ul class="sub-menu">
4236
<li>
43-
<a href="#/deposit_history.html">
37+
<a href="#/deposit/history">
4438
<i class="icon-puzzle"></i>Deposit History</span>
4539
</a>
4640
</li>
4741
<li>
48-
<a href="#/withdraw_history.html">
42+
<a href="#/withdraw_history">
4943
<i class="icon-paper-clip"></i> Withdraw History</span>
5044
</a>
5145
</li>
5246
<li>
53-
<a href="#/earning_history.html">
47+
<a href="#/earning_history">
5448
<i class="icon-check"></i> Earning History</span>
5549
</a>
5650
</li>
5751
</ul>
5852
</li>
5953
<li class="nav-item">
60-
<a href="#/advertisement_banner.html">
54+
<a href="#/advertisement_banner">
6155
<i class="icon-refresh"></i>
6256
<span class="title">Advertisement Banner</span>
6357
</a>
6458
</li>
6559
<li class="nav-item">
66-
<a href="#/your_referrals.html">
60+
<a href="#/your_referrals">
6761
<i class="icon-refresh"></i>
6862
<span class="title">Your Referrals</span>
6963
</a>
7064
</li>
7165
<li class="nav-item">
72-
<a href="#/security_center.html">
66+
<a href="#/security_center">
7367
<i class="icon-refresh"></i>
7468
<span class="title">Security Center</span>
7569
</a>

public/views/deposit_history.html

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<div class="row">
2+
<div class="col-md-12">
3+
<div class="portlet light">
4+
<div class="portlet-title tabbable-line">
5+
<div class="caption caption-md">
6+
<i class="icon-globe theme-font hide"></i>
7+
<span class="caption-subject font-blue-madison bold uppercase">Deposit History</span>
8+
</div>
9+
</div>
10+
<div class="portlet-body">
11+
<div class="row">
12+
<div class="col-sm-12">
13+
<div class="table-scrollable table-scrollable-borderless">
14+
<table class="table table-striped table-bordered table-advance table-hover">
15+
<thead>
16+
<tr>
17+
<th>Amount</th>
18+
<th>Plan</th>
19+
<th>Status</th>
20+
<th>Issued Date</th>
21+
<th>Expired Date</th>
22+
<th>Deposited Date</th>
23+
</tr>
24+
</thead>
25+
<tbody>
26+
<tr ng-repeat="(key, deposit) in vm.deposits">
27+
<td>{{ deposit.amount | currency }}</td>
28+
<td>{{ deposit.plan.name }}</td>
29+
<td>
30+
<span class="label label-sm label-warning" ng-if="deposit.status == 0">Pending</span>
31+
<span class="label label-sm label-success" ng-if="deposit.status == 1">Approved</span>
32+
<span class="label label-sm label-danger" ng-if="deposit.status == 3">Expired</span>
33+
</td>
34+
<td>{{ deposit.issue_date }}</td>
35+
<td>{{ deposit.expire_date }}</td>
36+
<td>{{ deposit.created_at }}</td>
37+
</tr>
38+
</tbody>
39+
</table>
40+
</div>
41+
</div>
42+
</div>
43+
<hr/>
44+
<div class="row">
45+
<div class="col-md-12">
46+
<div class="margiv-top-10">
47+
<a ui-sref="deposit" class="btn blue">
48+
Deposit
49+
</a>
50+
</div>
51+
</div>
52+
</div>
53+
</div>
54+
</div>
55+
</div>
56+
</div>

public/views/user_profile.html

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -99,16 +99,6 @@
9999
</div>
100100
</div>
101101
</div>
102-
<div class="col-sm-12">
103-
<div class="form-group">
104-
<div class="col-md-3">
105-
<label class="control-label">Direction</label>
106-
</div>
107-
<div class="col-md-9">
108-
<span ng-bind="vm.model.direction"></span>
109-
</div>
110-
</div>
111-
</div>
112102
</div>
113103
<hr/>
114104
<div class="row">

routes/api.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
Route::get('/plans', 'Api\PlanController@all');
2626

27-
2827
//Deposit
2928
Route::post('/deposit', 'DepositController@create');
29+
Route::get('/deposit/history', 'DepositController@history');
3030
});

0 commit comments

Comments
 (0)