<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

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

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