⚝
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
/
Models
/
View File Name :
OpdPatientDepartment.php
<?php namespace App\Models; use App\Traits\PopulateTenantID; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Support\Carbon; use Stancl\Tenancy\Database\Concerns\BelongsToTenant; use Str; /** * App\Models\OpdPatientDepartment * * @property int $id * @property int $patient_id * @property string $opd_number * @property string|null $height * @property string|null $weight * @property string|null $bp * @property string|null $symptoms * @property string|null $notes * @property Carbon $appointment_date * @property int|null $case_id * @property bool|null $is_old_patient * @property int|null $doctor_id * @property float $standard_charge * @property int $payment_mode * @property Carbon|null $created_at * @property Carbon|null $updated_at * @property-read Doctor|null $doctor * @property-read mixed $payment_mode_name * @property-read Patient $patient * @property-read PatientCase|null $patientCase * * @method static \Illuminate\Database\Eloquent\Builder|OpdPatientDepartment newModelQuery() * @method static \Illuminate\Database\Eloquent\Builder|OpdPatientDepartment newQuery() * @method static \Illuminate\Database\Eloquent\Builder|OpdPatientDepartment query() * @method static \Illuminate\Database\Eloquent\Builder|OpdPatientDepartment whereAppointmentDate($value) * @method static \Illuminate\Database\Eloquent\Builder|OpdPatientDepartment whereBp($value) * @method static \Illuminate\Database\Eloquent\Builder|OpdPatientDepartment whereCaseId($value) * @method static \Illuminate\Database\Eloquent\Builder|OpdPatientDepartment whereCreatedAt($value) * @method static \Illuminate\Database\Eloquent\Builder|OpdPatientDepartment whereDoctorId($value) * @method static \Illuminate\Database\Eloquent\Builder|OpdPatientDepartment whereHeight($value) * @method static \Illuminate\Database\Eloquent\Builder|OpdPatientDepartment whereId($value) * @method static \Illuminate\Database\Eloquent\Builder|OpdPatientDepartment whereIsOldPatient($value) * @method static \Illuminate\Database\Eloquent\Builder|OpdPatientDepartment whereNotes($value) * @method static \Illuminate\Database\Eloquent\Builder|OpdPatientDepartment whereOpdNumber($value) * @method static \Illuminate\Database\Eloquent\Builder|OpdPatientDepartment wherePatientId($value) * @method static \Illuminate\Database\Eloquent\Builder|OpdPatientDepartment wherePaymentMode($value) * @method static \Illuminate\Database\Eloquent\Builder|OpdPatientDepartment whereStandardCharge($value) * @method static \Illuminate\Database\Eloquent\Builder|OpdPatientDepartment whereSymptoms($value) * @method static \Illuminate\Database\Eloquent\Builder|OpdPatientDepartment whereUpdatedAt($value) * @method static \Illuminate\Database\Eloquent\Builder|OpdPatientDepartment whereWeight($value) * * @mixin \Eloquent */ class OpdPatientDepartment extends Model { use BelongsToTenant, PopulateTenantID; public $table = 'opd_patient_departments'; const PAYMENT_MODES = [ 1 => 'Cash', 2 => 'Cheque', ]; public $fillable = [ 'patient_id', 'opd_number', 'height', 'weight', 'bp', 'symptoms', 'notes', 'appointment_date', 'case_id', 'is_old_patient', 'doctor_id', 'standard_charge', 'payment_mode', 'custom_field', ]; /** * Validation rules * * @var array */ public static $rules = [ 'patient_id' => 'required', 'case_id' => 'required', 'appointment_date' => 'required', 'doctor_id' => 'required', 'standard_charge' => 'required', 'payment_mode' => 'required', 'weight' => 'numeric|max:200', 'height' => 'numeric|max:7', ]; /** * @var array */ protected $appends = ['payment_mode_name']; /** * Get the attributes that should be cast. * * @return array<string, string> */ protected function casts(): array { return [ 'id' => 'integer', 'patient_id' => 'integer', 'opd_number' => 'string', 'appointment_date' => 'datetime', 'height' => 'integer', 'weight' => 'integer', 'bp' => 'string', 'symptoms' => 'string', 'notes' => 'string', 'case_id' => 'integer', 'is_old_patient' => 'boolean', 'doctor_id' => 'integer', 'standard_charge' => 'double', 'payment_mode' => 'integer', 'custom_field' => 'array', ]; } public function patient(): BelongsTo { return $this->belongsTo(Patient::class, 'patient_id'); } public function patientCase(): BelongsTo { return $this->belongsTo(PatientCase::class, 'case_id'); } public function doctor(): BelongsTo { return $this->belongsTo(Doctor::class, 'doctor_id'); } public function opdDiagnoses(): HasMany { return $this->hasMany(OpdDiagnosis::class, 'opd_patient_department_id', 'id'); } public static function generateUniqueOpdNumber(): string { $opdNumber = strtoupper(Str::random(8)); while (true) { $isExist = self::whereOpdNumber($opdNumber)->exists(); if ($isExist) { self::generateUniqueOpdNumber(); } break; } return $opdNumber; } /** * @return mixed */ public function getPaymentModeNameAttribute() { return self::PAYMENT_MODES[$this->payment_mode]; } }