Anons79 Mini Shell

Directory : /home/aplikasiposinfo/public_html/hamrishealth.aplikasipos.info/app/Models/
Upload File :
Current File : /home/aplikasiposinfo/public_html/hamrishealth.aplikasipos.info/app/Models/Dokter.php

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class Dokter extends Model
{
    use HasFactory, SoftDeletes;
    
    protected $guarded = [];

    public function rekamMedis(){
        return $this->hasMany(DokterRekamMedis::class);
    }

    public function getTotalPelayananUtamaTahunAttribute($year = null){
        $result = 0;
        $year = $year ?? date('Y');
        foreach ($this->rekamMedis as $rm) {
            if ($rm->rekamMedis && $rm->jenis_terapis == 'Utama') {
                $tgl_periksa = strtotime($rm->rekamMedis->tgl_periksa);
                $actualYear = (int)date('Y', $tgl_periksa);  // Format 'Y' gives the four-digit year

                // Check if the date matches the desired and year
                if ($actualYear == $year) {
                    $result++;
                }
            }
        }

        return $result;
    }

    public function getTotalPelayananAsistenTahunAttribute($year = null){
        $result = 0;
        $year = $year ?? date('Y');
        foreach ($this->rekamMedis as $rm) {
            if ($rm->rekamMedis && $rm->jenis_terapis == 'Asisten') {
                $tgl_periksa = strtotime($rm->rekamMedis->tgl_periksa);
                $actualYear = (int)date('Y', $tgl_periksa);  // Format 'Y' gives the four-digit year

                // Check if the date matches the desired and year
                if ($actualYear == $year) {
                    $result++;
                }
            }
        }

        return $result;
    }

    public function getTotalPelayananUtamaBulanAttribute($month, $year = null){
        $result = 0;
        $year = $year ?? date('Y');
        foreach ($this->rekamMedis as $rm) {
            if ($rm->rekamMedis && $rm->jenis_terapis == 'Utama') {
                $tgl_periksa = strtotime($rm->rekamMedis->tgl_periksa);

                // Extract month and year components from the timestamp
                $actualMonth = (int)date('m', $tgl_periksa); // Format 'm' gives the month as a two-digit number
                $actualYear = (int)date('Y', $tgl_periksa);  // Format 'Y' gives the four-digit year

                // Check if the date matches the desired month and year
                if ($actualMonth == $month && $actualYear == $year) {
                    $result++;
                }
            }
        }

        return $result;
    }

    public function getTotalPelayananAsistenBulanAttribute($month, $year = null){
        $result = 0;
        $year = $year ?? date('Y');
        foreach ($this->rekamMedis as $rm) {
            if ($rm->rekamMedis && $rm->jenis_terapis == 'Asisten') {
                $tgl_periksa = strtotime($rm->rekamMedis->tgl_periksa);

                // Extract month and year components from the timestamp
                $actualMonth = (int)date('m', $tgl_periksa); // Format 'm' gives the month as a two-digit number
                $actualYear = (int)date('Y', $tgl_periksa);  // Format 'Y' gives the four-digit year

                // Check if the date matches the desired month and year
                if ($actualMonth == $month && $actualYear == $year) {
                    $result++;
                }
            }
        }

        return $result;
    }
}

Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]