select(); return $list; } public static function save($data){ $obj = new Grant(); $obj->save($data); return $obj; } public static function get($id){ return Grant::find($id)->toArray(); } public static function update($data){ $id = $data['grant_id']; unset($data['grant_id']); return Grant::where('id', $id)->update($data); } /// public static function getUserPermissions($openid) { if($openid == 'adminopenid'){ $grant = Grant::find(1); return $grant->permission; }else{ $currentUser = User::where('openid', $openid)->find(); if(!$currentUser) return false; $employee = Employee::where('uid', $currentUser->id)->find(); if(!$employee) return false; $grant = Grant::find($employee->grant_id); return $grant->permission; } } public static function delete($id){ if(Employee::where(['grant_id' => $id])->count() > 0){ return 'in_use'; }else{ return Grant::find($id)->delete(); } } }