<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class MstBloodType extends Model
{
    public static function getData($code='') 
    {
        if($code==''){
            $bloods = MstBloodType::get();

            $arrResult = array();
            foreach($bloods as $blood){
                 $arrResult[] = ['code' => $blood->code, 'name' => $blood->name];
            }
            return $arrResult;         
        } else {
            $bloods = MstBloodType::where('code', '=', $code)->get();
            
            $arrResult = array();
            foreach($bloods as $blood){
                 $arrResult[] = ['code' => $blood->code, 'name' => $blood->name];
            }
            return $arrResult;
        }
    }
}
