<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

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

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