Skip to content

Commit c1f33a7

Browse files
committed
Implementing view invoice
1 parent 031e92f commit c1f33a7

2 files changed

Lines changed: 56 additions & 0 deletions

File tree

app/Http/Controllers/InvoicesController.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use CleanPhp\Invoicer\Domain\Repository\InvoiceRepositoryInterface;
66
use CleanPhp\Invoicer\Domain\Repository\OrderRepositoryInterface;
77
use CleanPhp\Invoicer\Domain\Service\InvoicingService;
8+
use Illuminate\Http\Response;
89

910
/**
1011
* Class InvoicesController
@@ -52,6 +53,24 @@ public function indexAction()
5253
return view('invoices/index', ['invoices' => $invoices]);
5354
}
5455

56+
/**
57+
* @param $id
58+
* @return Response|\Illuminate\View\View
59+
*/
60+
public function viewAction($id)
61+
{
62+
$invoice = $this->invoiceRepository->getById($id);
63+
64+
if (!$invoice) {
65+
return new Response('', 404);
66+
}
67+
68+
return view('invoices/view', [
69+
'invoice' => $invoice,
70+
'order' => $invoice->getOrder()
71+
]);
72+
}
73+
5574
/**
5675
* @return \Illuminate\View\View
5776
*/
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
@extends('layouts.layout')
2+
3+
@section('content')
4+
<div class="page-header clearfix">
5+
<h2>Invoice #{{{ $invoice->getId() }}}</h2>
6+
</div>
7+
8+
<table class="table table-striped">
9+
<thead>
10+
<tr>
11+
<th colspan="2">Invoice Details</th>
12+
</tr>
13+
</thead>
14+
<tr>
15+
<th>Customer:</th>
16+
<td>
17+
<a href="/customers/edit/{{{ $order->getCustomer()->getId() }}}">
18+
{{{ $order->getCustomer()->getName() }}}</a>
19+
</td>
20+
</tr>
21+
<tr>
22+
<th>Order:</th>
23+
<td>
24+
<a href="/orders/view/{{{ $order->getId() }}}">
25+
{{{ $order->getOrderNumber() }}}</a>
26+
</td>
27+
</tr>
28+
<tr>
29+
<th>Description:</th>
30+
<td>{{{ $order->getDescription() }}}</td>
31+
</tr>
32+
<tr>
33+
<th>Total:</th>
34+
<td>$ {{{ number_format($invoice->getTotal(), 2) }}}</td>
35+
</tr>
36+
</table>
37+
@stop

0 commit comments

Comments
 (0)