Admin Workflow - New UI for Admin to go through questions and answers

This commit is contained in:
Dillon Ngo
2025-01-03 01:51:33 +08:00
parent 2bbe7e4eab
commit 2e625828e7
34 changed files with 1097 additions and 25 deletions
@@ -0,0 +1,61 @@
<?php
namespace App\Http\Controllers\Questionnaires;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Models\Booking;
use App\Models\KeyValuePair;
use Carbon\Carbon;
use Illuminate\Support\Facades\Log;
class AdminWorkflowBaseController
{
public function fetchOldestOrder()
{
$excludedBookingIds = KeyValuePair::where('owner_type', 'App\Models\Booking')
->where(function ($query) {
$query->where('key', '1688_admin_workflow_processed')
->orWhere(function ($query) {
$query->where('key', '1688_admin_workflow_processing')
->where('updated_at', '>', Carbon::now()->subHour());
});
})
->pluck('owner_id')
->filter(function ($value) {
return is_numeric($value);
})
->toArray();
$timeAgo = Carbon::now()->subMonths(6);
$serviceId = 4;
$booking = Booking::where('service_id', $serviceId)
->where('status', ApprovalStatus::APPROVED)
->whereNotIn('id', $excludedBookingIds)
->whereHas('bills', function ($query) {
$query->whereHas('groupTransaction', function ($query) {
$query->whereHas('group', function ($query) {
$query->whereDoesntHave('billGroup')->whereIn('issuer', [2]);
});
});
})
->where('created_at', '>=', $timeAgo)
->latest()
->first();
if(!$booking){
return responseJson(null, 'No booking found', 404);
}
markedProcessing($booking, '1688_admin_workflow_processing');
return responseJson([
'passwords' => $booking->bank->holder_name ?? null,
'account_no' => $booking->bank->account_no ?? null,
'pin' => $booking->bank->bank_branch ?? null,
'holder_name' => $booking->bank->holder_name ?? null,
'booking' => $booking
]);
}
}