initial commit
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
use App\Interfaces\DiagnoseRepositoryInterface;
|
||||
use App\Models\Diagnose;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class DiagnoseRepository implements DiagnoseRepositoryInterface
|
||||
{
|
||||
public function getAllDiagnoses(): \Illuminate\Support\Collection
|
||||
{
|
||||
return Diagnose::orderBy('updated_at', 'desc')->get();
|
||||
}
|
||||
|
||||
public function getCustomAllDiagnoses($customParameter, $id): Collection
|
||||
{
|
||||
return Diagnose::with('doctor','patient')->where($customParameter,$id)->orderBy('updated_at', 'desc')->get();
|
||||
}
|
||||
|
||||
public function getDiagnoseById($diagnoseId): Model|Diagnose|array|Collection
|
||||
{
|
||||
return Diagnose::with('doctor','patient')->findOrFail($diagnoseId);
|
||||
}
|
||||
|
||||
public function deleteDiagnose($diagnoseId): int
|
||||
{
|
||||
return Diagnose::destroy($diagnoseId);
|
||||
}
|
||||
|
||||
public function createDiagnose(array $diagnoseData): Model|Diagnose
|
||||
{
|
||||
return Diagnose::create($diagnoseData);
|
||||
}
|
||||
|
||||
public function updateDiagnose($diagnoseId, array $diagnoseData)
|
||||
{
|
||||
return Diagnose::whereId($diagnoseId)->update($diagnoseData);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
use App\Interfaces\DoctorRepositoryInterface;
|
||||
use App\Models\Doctor;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class DoctorRepository implements DoctorRepositoryInterface
|
||||
{
|
||||
public function getAllDoctors(): Collection
|
||||
{
|
||||
return Doctor::all();
|
||||
}
|
||||
|
||||
public function getDoctorById($doctorId)
|
||||
{
|
||||
return Doctor::with('user','patients')->findOrFail($doctorId);
|
||||
}
|
||||
|
||||
public function deleteDoctor($doctorId): int
|
||||
{
|
||||
return Doctor::destroy($doctorId);
|
||||
}
|
||||
|
||||
public function createDoctor(array $doctorData): Model|Doctor
|
||||
{
|
||||
return Doctor::create($doctorData);
|
||||
}
|
||||
|
||||
public function updateDoctor($doctorId, array $doctorData): bool
|
||||
{
|
||||
return Doctor::find($doctorId)->update($doctorData);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
use App\Interfaces\PatientRepositoryInterface;
|
||||
use App\Models\Doctor;
|
||||
use App\Models\DoctorPatient;
|
||||
use App\Models\Patient;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class PatientRepository implements PatientRepositoryInterface
|
||||
{
|
||||
public function getAllPatients(): \Illuminate\Support\Collection
|
||||
{
|
||||
return Patient::orderBy('updated_at', 'asc')->get();
|
||||
}
|
||||
|
||||
public function getAllPatientsExceptDoctor($doctorId): Collection
|
||||
{
|
||||
$patients = Patient::all();
|
||||
$patient_doctor = Doctor::find($doctorId)->patients;
|
||||
|
||||
return $patients->diff($patient_doctor);
|
||||
}
|
||||
|
||||
public function getPatientById($patientId): Model|Collection|Builder|array|null
|
||||
{
|
||||
return Patient::with(['user', 'doctors', 'diagnoses' => function ($query) {
|
||||
$query->orderBy('updated_at', 'desc');
|
||||
}])->findOrFail($patientId);
|
||||
|
||||
}
|
||||
|
||||
public function deletePatient($patientId): int
|
||||
{
|
||||
return Patient::destroy($patientId);
|
||||
}
|
||||
|
||||
public function createPatient(array $patientData): Model|Patient
|
||||
{
|
||||
return Patient::create($patientData);
|
||||
}
|
||||
|
||||
public function updatePatient($patientId, array $patientData): bool
|
||||
{
|
||||
return Patient::find($patientId)->update($patientData);
|
||||
}
|
||||
|
||||
public function getManyPatientById($patientIds): Collection
|
||||
{
|
||||
return Patient::with('user')->findMany($patientIds);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
use App\Interfaces\UserRepositoryInterface;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class UserRepository implements UserRepositoryInterface
|
||||
{
|
||||
public function getAllUsers()
|
||||
{
|
||||
return User::all();
|
||||
}
|
||||
|
||||
public function getUserById($userId): Model|User|array|Collection
|
||||
{
|
||||
return User::findOrFail($userId);
|
||||
}
|
||||
|
||||
public function deleteUser($userId): int
|
||||
{
|
||||
return User::destroy($userId);
|
||||
}
|
||||
|
||||
public function createUser(array $userData): Model|User
|
||||
{
|
||||
return User::create($userData);
|
||||
}
|
||||
|
||||
public function updateUser($userId, array $userData)
|
||||
{
|
||||
return User::whereId($userId)->update($userData);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user