-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
web.php
153 lines (109 loc) · 5.66 KB
/
web.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<?php
use Crater\Http\Controllers\V1\Admin\Auth\LoginController;
use Crater\Http\Controllers\V1\Admin\Expense\ShowReceiptController;
use Crater\Http\Controllers\V1\Admin\Report\CustomerSalesReportController;
use Crater\Http\Controllers\V1\Admin\Report\ExpensesReportController;
use Crater\Http\Controllers\V1\Admin\Report\ItemSalesReportController;
use Crater\Http\Controllers\V1\Admin\Report\ProfitLossReportController;
use Crater\Http\Controllers\V1\Admin\Report\TaxSummaryReportController;
use Crater\Http\Controllers\V1\Customer\Auth\LoginController as CustomerLoginController;
use Crater\Http\Controllers\V1\Customer\EstimatePdfController as CustomerEstimatePdfController;
use Crater\Http\Controllers\V1\Customer\InvoicePdfController as CustomerInvoicePdfController;
use Crater\Http\Controllers\V1\Customer\PaymentPdfController as CustomerPaymentPdfController;
use Crater\Http\Controllers\V1\Modules\ScriptController;
use Crater\Http\Controllers\V1\Modules\StyleController;
use Crater\Http\Controllers\V1\PDF\DownloadReceiptController;
use Crater\Http\Controllers\V1\PDF\EstimatePdfController;
use Crater\Http\Controllers\V1\PDF\InvoicePdfController;
use Crater\Http\Controllers\V1\PDF\PaymentPdfController;
use Crater\Models\Company;
use Illuminate\Support\Facades\Route;
/*
|--------------------------------------------------------------------------
| Frontend Routes
|--------------------------------------------------------------------------
|
*/
// Script Includes
// ----------------------------------------------
Route::get('/modules/styles/{style}', StyleController::class);
Route::get('/modules/scripts/{script}', ScriptController::class);
// Admin Auth
// ----------------------------------------------
Route::post('login', [LoginController::class, 'login']);
Route::get('auth/logout', function () {
Auth::guard('web')->logout();
});
// Customer auth
// ----------------------------------------------
Route::post('/{company:slug}/customer/login', CustomerLoginController::class);
Route::get('/{company:slug}/customer/logout', function () {
Auth::guard('customer')->logout();
});
Route::middleware('auth:sanctum')->prefix('reports')->group(function () {
// sales report by customer
//----------------------------------
Route::get('/sales/customers/{hash}', CustomerSalesReportController::class);
// sales report by items
//----------------------------------
Route::get('/sales/items/{hash}', ItemSalesReportController::class);
// report for expenses
//----------------------------------
Route::get('/expenses/{hash}', ExpensesReportController::class);
// report for tax summary
//----------------------------------
Route::get('/tax-summary/{hash}', TaxSummaryReportController::class);
// report for profit and loss
//----------------------------------
Route::get('/profit-loss/{hash}', ProfitLossReportController::class);
// download expense receipt
// -------------------------------------------------
Route::get('/expenses/{expense}/download-receipt', DownloadReceiptController::class);
Route::get('/expenses/{expense}/receipt', ShowReceiptController::class);
});
Route::middleware('pdf-auth')->group(function () {
// invoice pdf
// -------------------------------------------------
Route::get('/invoices/pdf/{invoice:unique_hash}', InvoicePdfController::class);
// estimate pdf
// -------------------------------------------------
Route::get('/estimates/pdf/{estimate:unique_hash}', EstimatePdfController::class);
// payment pdf
// -------------------------------------------------
Route::get('/payments/pdf/{payment:unique_hash}', PaymentPdfController::class);
});
// customer pdf endpoints for invoice, estimate and Payment
// -------------------------------------------------
Route::prefix('/customer')->group(function () {
Route::get('/invoices/{email_log:token}', [CustomerInvoicePdfController::class, 'getInvoice']);
Route::get('/invoices/view/{email_log:token}', [CustomerInvoicePdfController::class, 'getPdf'])->name('invoice');
Route::get('/estimates/{email_log:token}', [CustomerEstimatePdfController::class, 'getEstimate']);
Route::get('/estimates/view/{email_log:token}', [CustomerEstimatePdfController::class, 'getPdf'])->name('estimate');
Route::get('/payments/{email_log:token}', [CustomerPaymentPdfController::class, 'getPayment']);
Route::get('/payments/view/{email_log:token}', [CustomerPaymentPdfController::class, 'getPdf'])->name('payment');
});
// Setup for installation of app
// ----------------------------------------------
Route::get('/installation', function () {
return view('app');
})->name('install')->middleware('redirect-if-installed');
// Move other http requests to the Vue App
// -------------------------------------------------
Route::get('/admin/{vue?}', function () {
return view('app');
})->where('vue', '[\/\w\.-]*')->name('admin')->middleware(['install', 'redirect-if-unauthenticated']);
Route::get('{company:slug}/customer/{vue?}', function (Company $company) {
return view('app')->with([
'customer_logo' => get_customer_logo($company->id),
'current_theme' => get_customer_portal_theme($company->id)
]);
})->where('vue', '[\/\w\.-]*')->name('customer.login')->middleware(['install']);
Route::get('/', function () {
return view('app');
})->where('vue', '[\/\w\.-]*')->name('home')->middleware(['install', 'guest']);
Route::get('/reset-password/{token}', function () {
return view('app');
})->where('vue', '[\/\w\.-]*')->name('home')->middleware(['install', 'guest']);
Route::get('/login', function () {
return view('app');
})->where('vue', '[\/\w\.-]*')->name('login')->middleware(['install', 'guest']);