-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathroutes.php
46 lines (33 loc) · 1.11 KB
/
routes.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
use \Wzulfikar\EloquentSimpleLedger\Account;
use \Wzulfikar\EloquentSimpleLedger\LedgerHelper;
Route::group([
'as'=>'Ledger::',
'prefix'=>'ledger/{account}',
], function($account) use ($router){ // implicit binding for account
// bind account to \Wzulfikar\EloquentSimpleLedger\Account
$router->model('account', Account::class);
Route::get('', function($account){
$stats = LedgerHelper::accountStats($account);
if(Request::ajax()){
return $stats;
}
view()->addLocation(__DIR__ . '/views');
return view('eloquent-simple-ledger.index', compact('account', 'stats'));
});
Route::post('', function($account){
$transaction = LedgerHelper::record(Request::all(), $account);
if(isset($transaction['error']))
return $transaction;
return LedgerHelper::accountStats($account);
});
Route::get('summary', function($account){
return LedgerHelper::summary($account);
});
Route::get('transactions', function($account){
return LedgerHelper::transactions($account);
});
Route::get('accountStats', function($account){
return LedgerHelper::accountStats($account);
});
});