<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

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

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

    public static function getName($code) 
    {
        $res = MstShared::where('code', '=', $code)->first();
        return $res;
    }
}
