Browse Source

Sort invocies by date desc

pull/63/head
Nafies Luthfi 6 years ago
parent
commit
6895ce0c10
  1. 2
      app/Http/Controllers/Customers/InvoicesController.php
  2. 4
      app/Http/Controllers/Projects/InvoicesController.php
  3. 2
      resources/views/projects/invoices.blade.php

2
app/Http/Controllers/Customers/InvoicesController.php

@ -20,7 +20,7 @@ class InvoicesController extends Controller
*/ */
public function index(Customer $customer) public function index(Customer $customer)
{ {
$invoices = $customer->invoices()->orderBy('due_date')->get();
$invoices = $customer->invoices()->orderBy('date', 'desc')->get();
return view('customers.invoices', compact('customer', 'invoices')); return view('customers.invoices', compact('customer', 'invoices'));
} }

4
app/Http/Controllers/Projects/InvoicesController.php

@ -22,6 +22,8 @@ class InvoicesController extends Controller
{ {
$this->authorize('view-invoices', $project); $this->authorize('view-invoices', $project);
return view('projects.invoices', compact('project'));
$invoices = $project->invoices()->orderBy('date', 'desc')->get();
return view('projects.invoices', compact('project', 'invoices'));
} }
} }

2
resources/views/projects/invoices.blade.php

@ -33,7 +33,7 @@
<th class="col-md-1 text-center">{{ trans('app.action') }}</th> <th class="col-md-1 text-center">{{ trans('app.action') }}</th>
</thead> </thead>
<tbody> <tbody>
@forelse($project->invoices as $key => $invoice)
@forelse($invoices as $key => $invoice)
<tr> <tr>
<td class="text-center">{{ 1 + $key }}</td> <td class="text-center">{{ 1 + $key }}</td>
<td class="text-center">{{ $invoice->numberLink() }}</td> <td class="text-center">{{ $invoice->numberLink() }}</td>

Loading…
Cancel
Save