feat: Implement Fast Request feature with file upload and request management
This commit is contained in:
@@ -3,13 +3,29 @@
|
||||
namespace App\Http\Controllers\Client\Doctor;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Resources\Client\CaseResource;
|
||||
use App\Services\Document\CaseService;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Inertia\Inertia;
|
||||
|
||||
class CaseController extends Controller
|
||||
{
|
||||
protected CaseService $caseService;
|
||||
|
||||
public function __construct(CaseService $caseService)
|
||||
{
|
||||
$this->caseService = $caseService;
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
return Inertia::client('Dashboard/Cases/Index');
|
||||
$cases = $this->caseService->pendingForUser(Auth::user())
|
||||
->paginate(10)
|
||||
->withQueryString()
|
||||
->onEachSide(1);
|
||||
|
||||
return Inertia::client('Dashboard/Cases/Index', [
|
||||
'cases' => CaseResource::collection($cases),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,13 +3,26 @@
|
||||
namespace App\Http\Controllers\Client\Doctor;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Resources\Client\CaseResource;
|
||||
use App\Services\Document\CaseService;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Inertia\Inertia;
|
||||
|
||||
class DashboardController extends Controller
|
||||
{
|
||||
protected CaseService $caseService;
|
||||
|
||||
public function __construct(CaseService $caseService)
|
||||
{
|
||||
$this->caseService = $caseService;
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
return Inertia::client('Dashboard/Dashboard');
|
||||
$cases = $this->caseService->pendingForUser(Auth::user())->take(5)->get();
|
||||
|
||||
return Inertia::client('Dashboard/Dashboard', [
|
||||
'cases' => CaseResource::collection($cases),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,15 +3,31 @@
|
||||
namespace App\Http\Controllers\Client\Doctor;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Resources\Client\CaseResource;
|
||||
use App\Models\Document;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Services\Document\CaseService;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Inertia\Inertia;
|
||||
|
||||
class DocumentController extends Controller
|
||||
{
|
||||
protected CaseService $caseService;
|
||||
|
||||
public function __construct(CaseService $caseService)
|
||||
{
|
||||
$this->caseService = $caseService;
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
return Inertia::client('Dashboard/Documents/Index');
|
||||
$documents = $this->caseService->pendingForUser(Auth::user())
|
||||
->paginate(10)
|
||||
->withQueryString()
|
||||
->onEachSide(1);
|
||||
|
||||
return Inertia::client('Dashboard/Documents/Index', [
|
||||
'documents' => CaseResource::collection($documents),
|
||||
]);
|
||||
}
|
||||
|
||||
public function show(Document $document)
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
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 Illuminate\Support\Facades\Auth;
|
||||
|
||||
class FastRequestController extends Controller
|
||||
{
|
||||
protected FastRequestService $fastRequestService;
|
||||
|
||||
public function __construct(FastRequestService $fastRequestService)
|
||||
{
|
||||
$this->fastRequestService = $fastRequestService;
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
$pets = Auth::user()->pets()->latest()->get();
|
||||
|
||||
$doctors = User::where('level', UserEnum::Doctor->value)
|
||||
->latest()
|
||||
->get();
|
||||
|
||||
return response()->json([
|
||||
'pets' => PetArchiveResource::collection($pets),
|
||||
'doctors' => DoctorResource::collection($doctors),
|
||||
]);
|
||||
}
|
||||
|
||||
public function store(FastRequestRequest $request)
|
||||
{
|
||||
$document = $this->fastRequestService->create(
|
||||
Auth::user(),
|
||||
$request->validated(),
|
||||
$request->file('history_files', []),
|
||||
$request->file('scan_files', [])
|
||||
);
|
||||
|
||||
return response()->json([
|
||||
'document' => new FastRequestResource($document->load('pet')),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user