You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.0 KiB
PHTML

1 year ago
<?php
namespace App\Http\Controllers\Admin;
1 year ago
use App\Http\Controllers\Controller;
1 year ago
use App\Models\Sale;
use Illuminate\Http\Request;
class SaleController extends Controller
{
1 year ago
public function index(Request $request)
1 year ago
{
$query = Sale::with(['items.voucher', 'customer.level'])
1 year ago
->withCount(['items'])
->orderBy('updated_at', 'desc');
if ($request->q != '') {
$query->where('code', 'like', "%$request->q%")
->orWhereHas('customer', function ($query) use ($request) {
$query->where('name', 'like', "%$request->q%")
->orWhere('fullname', 'like', "%$request->q%")
->orWhere('username', 'like', "%$request->q%");
});
}
1 year ago
return inertia('Sale/Index', [
'query' => $query->paginate(),
]);
}
public function show(Sale $sale)
{
return inertia('Sale/Detail', [
1 year ago
'sale' => $sale->load(['items.voucher.location', 'customer.level']),
1 year ago
]);
}
}