Fix creating a system with the correct role, Fix need to have hold/active on creation

This commit is contained in:
Deon George
2022-03-01 22:07:08 +11:00
parent 6db16712ee
commit cf3b1947a4
2 changed files with 23 additions and 26 deletions

View File

@@ -31,6 +31,7 @@ class SystemController extends Controller
*/
public function add_address(Request $request,System $o)
{
// @todo a point address is failing validation
// @todo This should be admin of the zone
$this->authorize('admin',$o);
session()->flash('accordion','address');
@@ -161,7 +162,7 @@ class SystemController extends Controller
$oo->host_id = $request->post('host_id_new');
$oo->node_id = $request->post('node_id_new');
$oo->point_id = 0;
$oo->role = Address::NODE_NC;
$oo->role = Address::NODE_ACTIVE;
$oo->active = TRUE;
$o->addresses()->save($oo);
@@ -204,7 +205,7 @@ class SystemController extends Controller
$oo->node_id = $request->post('node_id');
$oo->point_id = $request->post('point_id');
$oo->hub_id = $request->post('hub_id') > 0 ? $request->post('hub_id') : NULL;
$oo->role = (! $oo->point_id) && $request->post('hub') ? Address::NODE_HC : Address::NODE_ACTIVE;
$oo->role = ((! $oo->point_id) && $request->post('hub')) ? Address::NODE_HC : Address::NODE_ACTIVE;
$oo->active = TRUE;
$o->addresses()->save($oo);