feat: enhance FastRequest functionality with shift scheduling and improve payment callback handling

This commit is contained in:
2026-09-21 04:45:57 +03:30
parent 5f19f82f86
commit 45da0103c0
11 changed files with 74 additions and 15 deletions
@@ -2,32 +2,32 @@
namespace App\Http\Controllers\Client;
use App\Enums\UserEnum;
use App\Http\Controllers\Controller;
use App\Http\Requests\Client\FastRequestRequest;
use App\Http\Resources\Client\DoctorResource;
use App\Http\Resources\Client\FastRequestResource;
use App\Http\Resources\Client\PetArchiveResource;
use App\Models\User;
use App\Services\Document\FastRequestService;
use App\Services\Shift\ShiftScheduleService;
use Illuminate\Support\Facades\Auth;
class FastRequestController extends Controller
{
protected FastRequestService $fastRequestService;
public function __construct(FastRequestService $fastRequestService)
protected ShiftScheduleService $shiftScheduleService;
public function __construct(FastRequestService $fastRequestService, ShiftScheduleService $shiftScheduleService)
{
$this->fastRequestService = $fastRequestService;
$this->shiftScheduleService = $shiftScheduleService;
}
public function create()
{
$pets = Auth::user()->pets()->latest()->get();
$doctors = User::where('level', UserEnum::Doctor->value)
->latest()
->get();
$doctors = $this->shiftScheduleService->availableDoctorsAt(now());
return response()->json([
'pets' => PetArchiveResource::collection($pets),
@@ -17,6 +17,7 @@ use App\Services\Payment\ZibalPaymentService;
use App\Services\Wallet\WalletService;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
class PaymentController extends Controller
{
@@ -68,7 +69,7 @@ class PaymentController extends Controller
}
if ($wasPending && $payment->status === PaymentStatusEnum::Paid) {
$this->settle($payment);
DB::transaction(fn () => $this->settle($payment));
}
session()->flash('payment_result', [
@@ -8,6 +8,7 @@ use App\Enums\DocumentModalityEnum;
use App\Enums\DocumentPriorityEnum;
use App\Enums\PetGenderEnum;
use App\Enums\PetTypeEnum;
use App\Enums\UserEnum;
class FastRequestRequest extends FormRequest
{
@@ -22,7 +23,7 @@ class FastRequestRequest extends FormRequest
'modality' => ['required', 'string', Rule::in(DocumentModalityEnum::values())],
'priority' => ['required', 'string', Rule::in(DocumentPriorityEnum::keys())],
'note' => ['nullable', 'string', 'max:1000'],
'pet_id' => ['nullable', 'exists:pets,id'],
'pet_id' => ['nullable', Rule::exists('pets', 'id')->where('owner_id', $this->user()->id)],
'pet' => ['required_without:pet_id', 'array'],
'pet.name' => ['required_without:pet_id', 'nullable', 'string', 'max:255'],
'pet.type' => ['required_without:pet_id', 'nullable', 'string', Rule::in(PetTypeEnum::keys())],
@@ -31,7 +32,7 @@ class FastRequestRequest extends FormRequest
'pet.age' => ['nullable', 'numeric', 'min:0', 'max:100'],
'pet.weight' => ['nullable', 'numeric', 'min:0', 'max:1000'],
'pet.sterilized' => ['nullable', 'boolean'],
'doctor_id' => ['nullable', 'exists:users,id'],
'doctor_id' => ['nullable', Rule::exists('users', 'id')->where('level', UserEnum::Doctor->value)],
'history_files' => ['nullable', 'array'],
'history_files.*' => ['file', 'image', 'max:10240'],
'scan_files' => ['nullable', 'array'],