<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

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

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