Anons79 Mini Shell

Directory : /home/aplikasiposinfo/public_html/elkahfisehatmandiri.aplikasipos.info/app/Helpers/
Upload File :
Current File : /home/aplikasiposinfo/public_html/elkahfisehatmandiri.aplikasipos.info/app/Helpers/Helper.php

<?php
namespace App\Helpers;

use Illuminate\Support\Facades\DB;
use App\Models\RekamMedis;
use App\Models\Pasien;
use App\Models\Level;
use App\Models\UserLog;
use App\Models\Profil;

use Auth;

class Helper {

    public static function hakAkses($nama_menu,$aksi){
        $cek = Level::whereHas('Menu',function ($q) use($nama_menu,$aksi)
        {
            $q->where('nama_menu', $nama_menu)
                ->where('aksi_menu', $aksi);
        })->where('id',Auth::user()->level->id)->count();
        if ( $cek > 0 ) {
            return true;
        } else {
            return false;
        }
    }

    public static function getMyIP()
    {
        $ipaddress = '';
        if (getenv('HTTP_CLIENT_IP'))
            $ipaddress = getenv('HTTP_CLIENT_IP');
        else if(getenv('HTTP_X_FORWARDED_FOR'))
            $ipaddress = getenv('HTTP_X_FORWARDED_FOR');
        else if(getenv('HTTP_X_FORWARDED'))
            $ipaddress = getenv('HTTP_X_FORWARDED');
        else if(getenv('HTTP_FORWARDED_FOR'))
            $ipaddress = getenv('HTTP_FORWARDED_FOR');
        else if(getenv('HTTP_FORWARDED'))
           $ipaddress = getenv('HTTP_FORWARDED');
        else if(getenv('REMOTE_ADDR'))
            $ipaddress = getenv('REMOTE_ADDR');
        else
            $ipaddress = 'UNKNOWN';
        return $ipaddress;
    }

    public static function addUserLog($action,$actionDetail = null,$ip = null)
    {
        
        if($ip == null){
            $ip = Helper::getMyIP();
        }
        

        UserLog::create([
            'action'=>$action,
            'action_detail'=>json_encode($actionDetail),
            'user_id'=>Auth::user()->id,
            'ip'=>$ip,
            'ip_detail'=>NULL
        ]);
        
    }

    public static function nomorPasien() {
        $pasien = Pasien::latest()->first();
        $nomor = "PSN-00000";
        if ($pasien) {
            $nomor = $pasien->nomor_pasien;
        }

        return ++$nomor;
    }

    public static function getNamaProfil() {
        $profil = Profil::first();

        return $profil->nama;
    }

    public static function getLogo() {
        $profil = Profil::first();

        return $profil->logo;
    }

    public static function nomorRekamMedis() {
        $rekam_medis = RekamMedis::latest()->first();
        $nomor = "RM-00000";

        if ($rekam_medis) {
            $nomor = $rekam_medis->nomor_rekam_medis;
        }

        return ++$nomor;

    }

    public static function cleanPrice($price)
    {
        $new_price = preg_replace("/[^0-9]/", "", $price);
        return $new_price;
    }

    public static function chartRekamMedis()
    {
        $result = [];

        for ($i=1; $i <= 12; $i++) { 
            $rekam_medis = RekamMedis::whereMonth('tgl_periksa', $i)->whereYear('tgl_periksa', date('Y'))->get();
            $totalHarga = 0;
            foreach ($rekam_medis as $rm) {
                $totalHarga += $rm->total;
            }

            $result[] = $totalHarga;
        }
        
        return $result;
    }
    

}

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