<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class MstOtherReason extends Model
{
    //
    public static function getData($code='') 
    {
        if($code==''){
            $types = MstOtherReason::get();

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