10.April 2026
This commit is contained in:
parent
a00c42e770
commit
f58c709945
208 changed files with 19280 additions and 2914 deletions
|
|
@ -11,6 +11,7 @@ use App\Services\Payment;
|
|||
use App\Services\Util;
|
||||
use App\User;
|
||||
use Carbon;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Request;
|
||||
|
||||
class PaymentCreditController extends Controller
|
||||
|
|
@ -183,6 +184,36 @@ class PaymentCreditController extends Controller
|
|||
return $query;
|
||||
}
|
||||
|
||||
public function stats(): JsonResponse
|
||||
{
|
||||
$this->setFilterVars();
|
||||
|
||||
$month = Request::get('credit_filter_month', session('credit_filter_month'));
|
||||
$year = Request::get('credit_filter_year', session('credit_filter_year'));
|
||||
$name = Request::get('credit_filter_name', '');
|
||||
|
||||
$dateStart = Carbon::parse('01.'.$month.'.'.$year)->format('Y-m-d');
|
||||
$dateEnd = Carbon::parse('01.'.$month.'.'.$year)->endOfMonth()->format('Y-m-d');
|
||||
|
||||
$baseQuery = UserCredit::query()
|
||||
->whereBetween('date', [$dateStart, $dateEnd]);
|
||||
|
||||
if ($name) {
|
||||
$baseQuery->whereHas('user.account', function ($query) use ($name) {
|
||||
$query->where('first_name', 'LIKE', '%'.$name.'%')
|
||||
->orWhere('last_name', 'LIKE', '%'.$name.'%');
|
||||
});
|
||||
}
|
||||
|
||||
$count = (clone $baseQuery)->count();
|
||||
$total = (clone $baseQuery)->sum('total');
|
||||
|
||||
return response()->json([
|
||||
'count' => $count,
|
||||
'total' => number_format((float) $total, 2, ',', '.'),
|
||||
]);
|
||||
}
|
||||
|
||||
public function datatable()
|
||||
{
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue