/**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store($mid, Request $request)
 {
     //
     $validator = Validator::make($request->all(), ['id' => array('required', 'regex:/^[\\d]+$/i')]);
     $member = Member::find($mid);
     if (NULL == $member) {
         return response()->json("", 404);
     } else {
         if ($validator->fails()) {
             return response()->json(["error" => "validator failed", "cause" => $validator->failed()], 400);
         } else {
             $subgroup = Subgroup::find($request->id);
             if (NULL == $subgroup) {
                 return response()->json("", 400);
             } else {
                 $member->subgroups()->attach($subgroup);
                 $member->load('devices', 'subgroups');
                 return response()->json($member, 200);
             }
         }
     }
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function members($id)
 {
     //
     $subgroup = Subgroup::find($id);
     if (NULL == $subgroup) {
         return response()->json("", 404);
     } else {
         $members = $subgroup->members;
         return response()->json($members, 200);
     }
 }