public function run()
 {
     DB::table('regions')->delete();
     $region = new Region();
     $region->code = 'ARG';
     $region->name = 'Argentina';
     $region->description = 'Nacional';
     $region->color = '#37ABC8';
     $region->icon = 'argentina';
     $region->save();
     $region = new Region();
     $region->code = 'CBA';
     $region->name = 'Córdoba';
     $region->description = 'Córdoba';
     $region->color = '#EE441E';
     $region->icon = 'cordoba';
     $region->parent_id = 1;
     $region->save();
     $region = new Region();
     $region->code = 'STA';
     $region->name = 'Santa Fé';
     $region->description = 'Santa Fé';
     $region->color = '#8FC521';
     $region->icon = 'santa_fe';
     $region->parent_id = 1;
     $region->save();
     $region = new Region();
     $region->code = 'MZA';
     $region->name = 'Mendoza';
     $region->description = 'Mendoza';
     $region->color = '#F3558A';
     $region->icon = 'mendoza';
     $region->parent_id = 1;
     $region->save();
     $userRegion = new UserRegion();
     $userRegion->user_id = 1;
     $userRegion->region_id = 1;
     $userRegion->admin = true;
     $userRegion->save();
 }
 public function store(Request $request)
 {
     $user = User::find($request['user']['sub']);
     $region = new Region();
     DB::transaction(function () use($request, $region, $user) {
         $region->name = $request->input('name');
         $region->description = $request->input('description');
         $region->color = $request->input('color')['code'];
         $region->icon = $request->input('icon')['code'];
         $region->parent_id = $request->input('parent_id');
         $region->save();
     });
     return $region;
 }