<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

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

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