fix add nas

This commit is contained in:
Ibnu Maksum
2023-10-03 15:03:47 +07:00
parent 6e3df253c6
commit 9e33a5740b
2 changed files with 16 additions and 26 deletions

View File

@ -2,24 +2,24 @@
class Radius {
public function getTableNas(){
public static function getTableNas(){
return ORM::for_table('nas', 'radius');
}
public function getTableCustomer(){
public static function getTableCustomer(){
return ORM::for_table('radcheck', 'radius');
}
public function getTablePackage(){
public static function getTablePackage(){
return ORM::for_table('radgroupreply', 'radius');
}
public function getTableUserPackage(){
public static function getTableUserPackage(){
return ORM::for_table('radusergroup', 'radius');
}
public function addNas($name, $ip, $ports, $secret, $description = "",$type = 'other', $server= null, $community= null){
$n = $this->getTableNas()->create();
public static function addNas($name, $ip, $ports, $secret, $description = "",$type = 'other', $server= null, $community= null){
$n = Radius::getTableNas()->create();
$n->nasname = $ip;
$n->shortname = $name;
$n->type = $type;
@ -31,8 +31,9 @@ class Radius {
$n->save();
return $n->id();
}
public function updateNas($id, $name, $ip, $ports, $secret, $description = "",$type = 'other', $server= null, $community= null){
$n = $this->getTableNas()->find_one($id);
public static function updateNas($id, $name, $ip, $ports, $secret, $description = "",$type = 'other', $server= null, $community= null){
$n = Radius::getTableNas()->find_one($id);
if(empty($n)){
return false;
}
@ -44,8 +45,7 @@ class Radius {
$n->description = $description;
$n->server = $server;
$n->community = $community;
$n->save();
return true;
return $n->save();
}
}