<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

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

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