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', 'customer.level'])
1 year ago
->withCount(['items'])
->orderBy('updated_at', 'desc');
if ($request->q != '') {
$query->where('code', 'ilike', "%$request->q%")
1 year ago
->orWhereHas('customer', function ($query) use ($request) {
$query->where('name', 'ilike', "%$request->q%")
->orWhere('fullname', 'ilike', "%$request->q%")
->orWhere('username', 'ilike', "%$request->q%");
1 year ago
});
}
1 year ago
return inertia('Sale/Index', [
'query' => $query->paginate(),
]);
}
public function show(Sale $sale)
{
return inertia('Sale/Detail', [
'sale' => $sale->load(['items', 'customer.level']),
1 year ago
]);
}
}