Api Report
This commit is contained in:
@@ -23,12 +23,12 @@ public function index(Request $request)
|
||||
$getLocation = SoftSettings::first();
|
||||
|
||||
$location = [
|
||||
'namaSoftware' => $getLocation->namasoft,
|
||||
'namaSystem' => $getLocation->namasystem,
|
||||
'LocatioName' => $getLocation->namalokasi,
|
||||
'namaSoftware' => $getLocation->namasoft ?? 'Lokasi belum di set',
|
||||
'namaSystem' => $getLocation->namasystem ?? 'Alamat belum di set',
|
||||
'LocatioName' => $getLocation->namalokasi ?? 'Alamat belum di set',
|
||||
'locationAddress' => $getLocation->alamatlokasi ?? 'location Undefined',
|
||||
'CompanyName' => $getLocation->namaperusahaan,
|
||||
'merchantID' => $getLocation->cabang_lokasi,
|
||||
'CompanyName' => $getLocation->namaperusahaan ?? 'Nama perusahaan belum di set',
|
||||
'merchantID' => $getLocation->cabang_lokasi ?? 'Merchant belum di set',
|
||||
];
|
||||
|
||||
if (!array_key_exists('gate', $_GET)) {
|
||||
|
||||
78
app/Http/Controllers/Api/V1/LaporanController.php
Normal file
78
app/Http/Controllers/Api/V1/LaporanController.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\V1;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\TransaksiParkir;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class LaporanController extends Controller
|
||||
{
|
||||
public function harian(Request $request)
|
||||
{
|
||||
|
||||
$tanggal = $request->input('tanggal');
|
||||
$shift = $request->input('shift');
|
||||
$cashless = $request->input('cashless');
|
||||
|
||||
// Mulai query dengan select dasar
|
||||
|
||||
// Tentukan kolom tanggal berdasarkan input shift
|
||||
// $dateField = ($shift == 1) ? 'pklogin' : 'waktu_keluar';
|
||||
$dateField = ($shift == null) ? 'waktu_keluar' : 'pklogin';
|
||||
$query = TransaksiParkir::selectRaw('COUNT(*) as jml, SUM(bayar_keluar) as VALUE, DATE(' . $dateField . ') as tanggal');
|
||||
// $query->selectRaw("DATE($dateField) as tanggal");
|
||||
|
||||
// Terapkan filter tanggal berdasarkan input
|
||||
if ($tanggal) {
|
||||
$query->whereDate($dateField, '=', $tanggal);
|
||||
}
|
||||
|
||||
// Terapkan filter cara bayar
|
||||
if ($cashless == 1) {
|
||||
$query->where('cara_bayar', 3);
|
||||
}
|
||||
|
||||
// Terapkan grouping dan sorting
|
||||
// $query->groupBy('tanggal')
|
||||
// ->orderBy('tanggal');
|
||||
|
||||
$query->groupByRaw("DATE($dateField)")
|
||||
->orderByRaw("DATE($dateField)");
|
||||
|
||||
|
||||
$result = $query->get();
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'result' => $result,
|
||||
]);
|
||||
|
||||
// $tanggal = $request->input('tanggal');
|
||||
// $shift = $request->input('shift');
|
||||
// $cashless = $request->input('cashless');
|
||||
|
||||
// $query = TransaksiParkir::selectRaw('COUNT (*) as jml, SUM(bayar_keluar) as VALUE');
|
||||
// $dateField = ($shift == 1) ? 'pklogin' : 'waktu_keluar';
|
||||
// $query->selectRaw("DATE($dateField) as tanggal");
|
||||
|
||||
// if ($tanggal) {
|
||||
// $query->whereDate($dateField, '=', $tanggal);
|
||||
// }
|
||||
|
||||
// if ($cashless == 1) {
|
||||
// $query->where('cara_bayar', 3);
|
||||
// } else {
|
||||
// $query->where('cara_bayar', 2);
|
||||
// }
|
||||
|
||||
// $query->groupBy('tanggal')
|
||||
// ->orderBy('tanggal');
|
||||
// $result = $query->get();
|
||||
|
||||
// return response()->json([
|
||||
// 'status' => 'success',
|
||||
// 'result' => $result,
|
||||
// ]);
|
||||
}
|
||||
}
|
||||
@@ -141,7 +141,7 @@ public function index(Request $request)
|
||||
$query = $this->getData($request)
|
||||
->whereRaw('? BETWEEN awal AND akhir', [now()])
|
||||
->first();
|
||||
Log::info($query->toSql());
|
||||
// Log::info($query->toSql());
|
||||
|
||||
// Log::info('Data : ' . $query);
|
||||
if ($query) {
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use App\Http\Controllers\Api\V1\ConfigParameter;
|
||||
use App\Http\Controllers\Api\V1\LaporanController;
|
||||
use App\Http\Controllers\Api\V1\TransaksiMember;
|
||||
use App\Http\Controllers\Api\V1\TransaksiParkir;
|
||||
|
||||
@@ -28,3 +29,7 @@
|
||||
Route::resource('stiker', TransaksiMember::class);
|
||||
Route::resource('parkir', TransaksiParkir::class);
|
||||
});
|
||||
|
||||
Route::prefix('report')->group(function () {
|
||||
Route::post('harian', [LaporanController::class, 'harian']);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user