diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php
index ae2f68fb..2eb7e8c1 100644
--- a/app/Exceptions/Handler.php
+++ b/app/Exceptions/Handler.php
@@ -56,6 +56,10 @@ class Handler extends ExceptionHandler
], 404);
}
+ if ($exception->getCode() === 403) {
+ return redirect('/');
+ }
+
return parent::render($request, $exception);
}
}
diff --git a/routes/web.php b/routes/web.php
index eb443982..107643c2 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -22,105 +22,100 @@ Route::get('password/reset/{token}', 'Auth\ResetPasswordController@showResetForm
Route::post('password/reset', 'Auth\ResetPasswordController@postReset')->name('password.reset');
Route::group(['middleware' => ['role:admin']], function() {
- try {
- Route::get('/report/x1', function(){
- $bookings = Booking::where('admin_status', '>=', 3)->where('term', 'like', 'x1_%')->where('is_cancel', false)->where('user_id', '!=', 1)->get();
- $months = $bookings->groupBy(function($item) {
- return $item->created_at->format('Y-m');
- });
-
- foreach($months as $month => $bookings){
- echo "
".Carbon::parse($month)->format('m-Y').": ".$bookings->sum('bia')." MYR
";
- $days = $bookings->groupBy(function($item){
- return $item->created_at->format('Y-m-d');
- });
-
- foreach($days as $day => $bookings ){
- echo "".Carbon::parse($day)->format('d-m-Y').": ".$bookings->sum('bia')." MYR
";
- }
-
- }
-
+ Route::get('/report/x1', function(){
+ $bookings = Booking::where('admin_status', '>=', 3)->where('term', 'like', 'x1_%')->where('is_cancel', false)->where('user_id', '!=', 1)->get();
+ $months = $bookings->groupBy(function($item) {
+ return $item->created_at->format('Y-m');
});
- Route::get('/report/x2', function(){
- $bookings = Booking::where('admin_status', '>=', 3)->where('term', 'like', 'x2_%')->where('is_cancel', false)->where('user_id', '!=', 1)->get();
- $months = $bookings->groupBy(function($item) {
- return $item->created_at->format('Y-m');
+
+ foreach($months as $month => $bookings){
+ echo "".Carbon::parse($month)->format('m-Y').": ".$bookings->sum('bia')." MYR
";
+ $days = $bookings->groupBy(function($item){
+ return $item->created_at->format('Y-m-d');
});
- foreach($months as $month => $bookings){
- echo "".Carbon::parse($month)->format('m-Y').": ".$bookings->sum('bia')." MYR
";
- $days = $bookings->groupBy(function($item){
- return $item->created_at->format('Y-m-d');
- });
-
- foreach($days as $day => $bookings ){
- echo "".Carbon::parse($day)->format('d-m-Y').": ".$bookings->sum('bia')." MYR
";
- }
-
+ foreach($days as $day => $bookings ){
+ echo "".Carbon::parse($day)->format('d-m-Y').": ".$bookings->sum('bia')." MYR
";
}
+ }
+
+ });
+ Route::get('/report/x2', function(){
+ $bookings = Booking::where('admin_status', '>=', 3)->where('term', 'like', 'x2_%')->where('is_cancel', false)->where('user_id', '!=', 1)->get();
+ $months = $bookings->groupBy(function($item) {
+ return $item->created_at->format('Y-m');
});
- Route::get('/po-approval', function(){
- $approvedInvoices = InvoiceStatuses::where('status', 'approve')->distinct()->get(['invoice_id'])->pluck('invoice_id');
- $pendingChangeInvoices = InvoiceStatuses::where('status', 'request_change')->distinct()->get(['invoice_id'])->pluck('invoice_id');
- $invoices = InvoiceStatuses::whereNotIn('invoice_id', $approvedInvoices)->whereNotIn('invoice_id', $pendingChangeInvoices)->get();
- echo "Total PO Pending Approval: ".count($invoices)."
";
- foreach ($invoices as $invoice){
- echo "".$invoice->invoice->booking->id."
";
- }
- $bookings = Booking::where('admin_status', 6)->where(function($q){
- $q->WhereDoesntHave('invoice')->WhereDoesntHave('purchaseOrder');
- })->get();
- $months = $bookings->groupBy(function($item) {
- return $item->created_at->format('Y-m');
+ foreach($months as $month => $bookings){
+ echo "".Carbon::parse($month)->format('m-Y').": ".$bookings->sum('bia')." MYR
";
+ $days = $bookings->groupBy(function($item){
+ return $item->created_at->format('Y-m-d');
});
- echo "Total Po Pending Customer Update: ".count($bookings)."
";
- foreach ($months as $month => $bookings) {
- echo "".$month."(".count($bookings).")
";
- foreach ($bookings as $booking) {
- echo "".$booking->id." ".$booking->user->marking." / ".$booking->created_at."
";
- }
- echo "
";
+
+ foreach($days as $day => $bookings ){
+ echo "".Carbon::parse($day)->format('d-m-Y').": ".$bookings->sum('bia')." MYR
";
}
- })->name('po.approval');
+ }
- Route::get('/po-approved', function(){
- $approvedInvoices = InvoiceStatuses::where('status', 'approve')->distinct()->get(['invoice_id'])->pluck('invoice_id');
- $oldCompletedInvoices = Invoice::where('invoice_path', '!=', '')->orWhereNotNull('invoice_path')->get();
- $newCompletedInvoices = Invoice::whereIn('id', $approvedInvoices)->get();
- $total = count($oldCompletedInvoices) + count($newCompletedInvoices);
- echo "Total Po Approved: ".$total."
";
- foreach ($newCompletedInvoices as $invoice){
- echo "".$invoice->booking->id."
";
- }
- foreach ($oldCompletedInvoices as $invoice){
- echo "".$invoice->booking->id."
";
- }
- })->name('po.approved');
+ });
+ Route::get('/po-approval', function(){
+ $approvedInvoices = InvoiceStatuses::where('status', 'approve')->distinct()->get(['invoice_id'])->pluck('invoice_id');
+ $pendingChangeInvoices = InvoiceStatuses::where('status', 'request_change')->distinct()->get(['invoice_id'])->pluck('invoice_id');
+ $invoices = InvoiceStatuses::whereNotIn('invoice_id', $approvedInvoices)->whereNotIn('invoice_id', $pendingChangeInvoices)->get();
+ echo "Total PO Pending Approval: ".count($invoices)."
";
+ foreach ($invoices as $invoice){
+ echo "".$invoice->invoice->booking->id."
";
+ }
- Route::get('/old-invoices', function(){
- $bookings = \App\Booking::where('status', 6)->where('user_id', '!=', 1)->whereHas('purchaseOrder', function($q){
- $q->whereNotNull('image_path');
- })->get();
- $months = $bookings->groupBy(function($item) {
- return $item->created_at->format('Y-m');
- });
- echo "Total pending invoices:".count($bookings)."
";
- foreach ($months as $month => $bookings) {
- echo "".$month."(".count($bookings).")
";
- foreach ($bookings as $booking) {
- echo "".$booking->id." date: ".$booking->created_at."
";
- }
- echo "
";
+ $bookings = Booking::where('admin_status', 6)->where(function($q){
+ $q->WhereDoesntHave('invoice')->WhereDoesntHave('purchaseOrder');
+ })->get();
+ $months = $bookings->groupBy(function($item) {
+ return $item->created_at->format('Y-m');
+ });
+ echo "Total Po Pending Customer Update: ".count($bookings)."
";
+ foreach ($months as $month => $bookings) {
+ echo "".$month."(".count($bookings).")
";
+ foreach ($bookings as $booking) {
+ echo "".$booking->id." ".$booking->user->marking." / ".$booking->created_at."
";
}
- })->name('invoice.old');
- } catch (\Exception $exception){
- return redirect('login');
- }
+ echo "
";
+ }
+ })->name('po.approval');
+
+ Route::get('/po-approved', function(){
+ $approvedInvoices = InvoiceStatuses::where('status', 'approve')->distinct()->get(['invoice_id'])->pluck('invoice_id');
+ $oldCompletedInvoices = Invoice::where('invoice_path', '!=', '')->orWhereNotNull('invoice_path')->get();
+ $newCompletedInvoices = Invoice::whereIn('id', $approvedInvoices)->get();
+ $total = count($oldCompletedInvoices) + count($newCompletedInvoices);
+ echo "Total Po Approved: ".$total."
";
+ foreach ($newCompletedInvoices as $invoice){
+ echo "".$invoice->booking->id."
";
+ }
+ foreach ($oldCompletedInvoices as $invoice){
+ echo "".$invoice->booking->id."
";
+ }
+ })->name('po.approved');
+
+ Route::get('/old-invoices', function(){
+ $bookings = \App\Booking::where('status', 6)->where('user_id', '!=', 1)->whereHas('purchaseOrder', function($q){
+ $q->whereNotNull('image_path');
+ })->get();
+ $months = $bookings->groupBy(function($item) {
+ return $item->created_at->format('Y-m');
+ });
+ echo "Total pending invoices:".count($bookings)."
";
+ foreach ($months as $month => $bookings) {
+ echo "".$month."(".count($bookings).")
";
+ foreach ($bookings as $booking) {
+ echo "".$booking->id." date: ".$booking->created_at."
";
+ }
+ echo "
";
+ }
+ })->name('invoice.old');
});