⚝
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 :
IpdChargeRepository.php
<?php namespace App\Repositories; use App\Models\Charge; use App\Models\ChargeCategory; use App\Models\IpdCharge; use App\Models\IpdPatientDepartment; use App\Models\Notification; use App\Models\Receptionist; use Exception; use Filament\Notifications\Notification as FilamentNotification; use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException; /** * Class IpdChargeRepository * * @version September 9, 2020, 1:55 pm UTC */ class IpdChargeRepository extends BaseRepository { /** * @var array */ protected $fieldSearchable = [ 'ipd_patient_department_id', 'date', 'charge_type_id', 'charge_category_id', 'charge_id', 'standard_charge', 'applied_charge', ]; /** * Return searchable fields */ public function getFieldsSearchable(): array { return $this->fieldSearchable; } /** * Configure the Model **/ public function model() { return IpdCharge::class; } public function getChargeCategories($chargeTypeId) { return ChargeCategory::where('charge_type', $chargeTypeId)->pluck('name', 'id'); } public function getCharges($chargeCategoryId) { return Charge::where('charge_category_id', $chargeCategoryId)->pluck('code', 'id'); } public function getChargeStandardRate($chargeId, $isEdit, $onceOnEditRender, $ipdChargeId) { $charge = null; if (! $isEdit) { $charge = Charge::where('id', $chargeId)->value('standard_charge'); } else { if ($onceOnEditRender != null) { $charge = IpdCharge::where('id', $ipdChargeId)->first(); } else { $charge = Charge::where('id', $chargeId)->first(); if ($charge != null) { $charge->setAttribute('applied_charge', $charge->standard_charge); } } } return $charge; } public function createNotification($input) { try { $patient = IpdPatientDepartment::with('patient.user')->where('id', $input['ipd_patient_department_id'])->first(); $receptionists = Receptionist::pluck('user_id', 'id')->toArray(); $userIds = [ $patient->patient->user_id => Notification::NOTIFICATION_FOR[Notification::PATIENT], ]; foreach ($receptionists as $key => $userId) { $userIds[$userId] = Notification::NOTIFICATION_FOR[Notification::RECEPTIONIST]; } $users = getAllNotificationUser($userIds); foreach ($users as $key => $notification) { if ($notification == Notification::NOTIFICATION_FOR[Notification::PATIENT]) { $title = $patient->patient->user->full_name.' your IPD charge has been created.'; } else { $title = $patient->patient->user->full_name.' IPD charge has been created.'; } addNotification([ Notification::NOTIFICATION_TYPE['IPD Charge'], $key, $notification, $title, ]); } } catch (Exception $e) { FilamentNotification::make() ->danger() ->title($e->getMessage()) ->send(); // throw new UnprocessableEntityHttpException($e->getMessage()); } } }