public function postEditMsgType()
 {
     $validator = Validator::make(array('id' => Input::get('type_id')), $this->validate_id_arr);
     if ($validator->fails()) {
         return json_encode(array(false, "Invalid notification type ID"));
     }
     $type_id = Input::get('type_id');
     $type_name = Input::get('type_name');
     $rows = Input::get('data');
     try {
         $msg_type = MessageType::find($type_id);
         $msg_type->type_name = $type_name;
         $msg_type->save();
     } catch (Exception $e) {
         return json_encode(array(false, "Failed to update notification type"));
     }
     try {
         foreach ($rows as $row) {
             if (isset($row['column_id']) && strlen(trim($row['column_id'])) > 0) {
                 $column_id = $row['column_id'];
                 $column = MessageTypeColums::find($column_id);
             } else {
                 $column = new MessageTypeColums();
             }
             $column->type_id = $type_id;
             $column->key = $row['key'];
             $column->value = $row['value'];
             $column->save();
         }
         //            Session::put('msg', 'Message Type and Columns Updated Successfully');
         return json_encode(array(true, "Notification type and columns updated successfully"));
     } catch (Exception $e) {
         if ($e->getCode() == 23000) {
             $msg = " : Keys must be unique";
         } else {
             $msg = "";
         }
         return json_encode(array(false, "Failed to update notification type columns " . $msg));
     }
 }