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.

40 lines
1.1 KiB
PHTML

<?php
namespace App\Http\Controllers\Customer;
use App\Http\Controllers\Controller;
use App\Models\Sale;
use Illuminate\Http\Request;
use Illuminate\Support\Carbon;
class TransactionController extends Controller
{
public function index(Request $request)
{
$query = Sale::where('customer_id', auth()->id())
->orderBy('created_at', 'desc');
$start_date = now()->startOfMonth();
$end_date = now()->endOfMonth();
if ($request->startDate != '' && $request->endDate != '') {
$start_date = Carbon::parse($request->startDate);
$end_date = Carbon::parse($request->endDate);
}
$query->whereBetween('created_at', [$start_date, $end_date]);
return inertia('Trx/Index', [
'query' => $query->paginate(20),
'_start_date' => $start_date->format('m/d/Y'),
'_end_date' => $end_date->format('m/d/Y')
]);
}
public function show(Sale $sale)
{
return inertia('Trx/Detail', [
1 year ago
'sale' => $sale->load(['items.voucher.locationProfile.location']),
]);
}
}