Skip to content

Commit

Permalink
refactor: ORM query function in Controllers/Api/Invoice/SaleInvoiceCo…
Browse files Browse the repository at this point in the history
…ntroller.php
  • Loading branch information
JaberWiki authored Sep 24, 2023
1 parent ea2a1e6 commit 1b0ab5e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/Http/Controllers/Api/Invoice/SaleInvoiceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ public function index(Request $request)
$per_page = $request->query('per_page') && $request->query('per_page') < 100 ? $request->query('per_page') : 10;
$search = $request->query('search');

$sales = Invoice::where('type', 'sale');
$sales = Invoice::whereType('sale');

$sales->when($search, function ($query, $search) {
$query->where('invoice_ref', 'LIKE', '%'.$search.'%');
});

$sales = $sales->orderBy('id', 'desc')->paginate($per_page);
$sales = $sales->latest()->paginate($per_page);

return SaleListResource::collection($sales);
}
Expand Down

0 comments on commit 1b0ab5e

Please sign in to comment.