<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

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

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