⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.19
Server IP:
178.33.27.10
Server:
Linux cpanel.dev-unit.com 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64
Server Software:
Apache/2.4.57 (Unix) OpenSSL/1.0.2k-fips
PHP Version:
8.2.11
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
home
/
id
/
hospital.dev-unit.com
/
app
/
Repositories
/
View File Name :
InvestigationReportRepository.php
<?php namespace App\Repositories; use App\Models\Doctor; use App\Models\InvestigationReport; use App\Models\Patient; use Auth; use Illuminate\Database\Eloquent\Builder; use Illuminate\Support\Collection; use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException; /** * Class InvestigationReportRepository * * @version February 21, 2020, 9:02 am UTC */ class InvestigationReportRepository extends BaseRepository { /** * @var array */ protected $fieldSearchable = [ 'patient_id', 'date', 'title', 'description', 'doctor_id', 'status', ]; /** * Return searchable fields */ public function getFieldsSearchable(): array { return $this->fieldSearchable; } /** * Configure the Model **/ public function model() { return InvestigationReport::class; } public function getPatients(): Collection { $user = Auth::user(); if ($user->hasRole('Doctor')) { $patients = getPatientsList($user->owner_id); } else { $patients = Patient::with('patientUser') ->whereHas('patientUser', function (Builder $query) { $query->where('status', 1); })->get()->pluck('patientUser.full_name', 'id')->sort(); } return $patients; } public function getDoctors() { /** @var Doctor $doctors */ $doctors = Doctor::with('doctorUser')->get()->where('doctorUser.status', '=', 1)->pluck('doctorUser.full_name', 'id')->sort(); return $doctors; } public function store(array $input): bool { try { /** @var InvestigationReport $report */ $report = InvestigationReport::create($input); if (! empty($input['attachment'])) { $report->addMedia($input['attachment'])->toMediaCollection(InvestigationReport::COLLECTION_REPORTS, config('app.media_disc')); } return true; } catch (\Exception $e) { throw new UnprocessableEntityHttpException($e->getMessage()); } } public function update($input, $id): bool { /** @var InvestigationReport $report */ $report = InvestigationReport::findOrFail($id); try { $report->update($input); if (! empty($input['attachment'])) { $report->clearMediaCollection(InvestigationReport::COLLECTION_REPORTS); $report->addMedia($input['attachment'])->toMediaCollection(InvestigationReport::COLLECTION_REPORTS, config('app.media_disc')); } if ($input['avatar_remove'] == 1 && isset($input['avatar_remove']) && ! empty($input['avatar_remove'])) { removeFile($report, InvestigationReport::COLLECTION_REPORTS); } return true; } catch (\Exception $e) { throw new UnprocessableEntityHttpException($e->getMessage()); } } }