<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

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

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