<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

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

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